Gar*_*eth 2 excel vba identifier
寻找关于将值的Id传递到excel VBA中的参数的最佳方法的建议.
基本上我试图复制获取值而不是文本本身,例如在html中:
<option value="1">Option one</option>
Run Code Online (Sandbox Code Playgroud)
将返回1.我可以将Id连接到字符串的开头或结尾,例如:
.additem varList(0, 1) & " | " & varList(1, 1)
Run Code Online (Sandbox Code Playgroud)
但是,如果有意义,我正在寻找一个"更清洁"的选择?
干杯
使用至少2列创建组合框.这可以使用ColumnCount属性,VBE或VBA代码进行设置.

然后,您可以调整ColumnWidths属性以使其中一列的宽度为0,以便用户不会显示/可见.
在填充组合框时,只需将ID放在ComboBox的一列中,然后将值放在另一个可见列中.除非您调整列宽,否则界面将如下所示

使用BoundColumnComboBox的返回适当的值,也可以做在一些迭代选择的项目(S)和参考索引的位置:
Debug.Print Me.ComboBox.List(0, 0) '# Display the first row item in the first column
Debug.Print Me.ComboBox1.List(0, 1) '# Display the first row item in the SECOND column
Run Code Online (Sandbox Code Playgroud)