简体   繁体   English

VBA 用户表单 Combobox - 需要帮助

[英]VBA Userform Combobox - Help required

Good morning,早上好,

I am trying to populate a combobox with selective data, but cannot get my head around what i need to do.我正在尝试使用选择性数据填充 combobox,但无法理解我需要做什么。 I have some experience with SQL and can use a sql query to replicate what I need, but in Excel VBA I am struggling.我对 SQL 有一些经验,可以使用 sql 查询来复制我需要的内容,但在 Excel VBA 中我很挣扎。 It is probably quite simple, but I am having a senior moment I think!!这可能很简单,但我想我正在度过一个高级的时刻!

I have a table with two Columns我有一个包含两列的表

Column one (C1) holds unique serial numbers, whereas column 2 (C2) holds equipment type第一列 (C1) 包含唯一序列号,而第二列 (C2) 包含设备类型

In sql the query would be "SELECT C1 From Table WHERE C2 = $string" where $string would be the Value of selected equipment type.在 sql 中,查询将是“SELECT C1 From Table WHERE C2 = $string”,其中 $string 是所选设备类型的值。 This would then populate the dropdown using a foreach instruction然后,这将使用 foreach 指令填充下拉列表

The table shows该表显示

Table example表格示例

In the example, how would I show just the serial numbers relating to the selected equipment type在示例中,我将如何仅显示与所选设备类型相关的序列号

Any advice would be much appreciated任何建议将不胜感激

I have created a range called 'oNumbers' on a separate sheet which contains all the serial numbers, and have a cell which contains the equipment type code, but other than that I cannot fathom out what I need to do我在单独的工作表上创建了一个名为“oNumbers”的范围,其中包含所有序列号,并且有一个包含设备类型代码的单元格,但除此之外我无法理解我需要做什么

Google can help you on all kinds of VBA questions with examples - like https://analysistabs.com/vba-code/excel-userform/combobox/ Google 可以通过示例帮助您解决各种 VBA 问题 - 例如https://analystabs.com/vba-code/excel-userform/combobox/

This is not a chat forum;-)这不是聊天论坛;-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM