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";
With ComboBox1
.AddItem "Item1"
.AddItem "Item2"
End With
或者
ActiveSheet.Shapes("ComboBox1").ListFillRange = "A1:A10"
当我从 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 中,这两条注释行似乎不起作用。希望有帮助吗?