1

How to set combo box text field and value field in Excel VBA, like we set for dropdown list in web applications, For example,

DropdownList.DataTextField ="EmpName";
DropdownList.DataValueField = "EmpCode";
4

2 回答 2

1
With ComboBox1 
   .AddItem "Item1" 
   .AddItem "Item2"
End With 

或者

ActiveSheet.Shapes("ComboBox1").ListFillRange = "A1:A10" 
于 2013-06-12T13:44:02.283 回答
0

当我从 Access VBA 创建 Excel ComboBox 时,我使用了以下 sytnax:

With ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1")
    With .Object
        .TextAlign = 2
        '.LinkedCell = "D6"
        '.ListFillRange = "G16:G23"
    End With
End With

但在 Excel 中,这两条注释行似乎不起作用。希望有帮助吗?

于 2013-06-12T13:46:27.340 回答