如何在Excel VBA中设置组合框文本字段和值字段,就像我们在Web应用程序中设置下拉列表一样,例如,
DropdownList.DataTextField ="EmpName";
DropdownList.DataValueField = "EmpCode";
答案 0 :(得分:1)
With ComboBox1
.AddItem "Item1"
.AddItem "Item2"
End With
或
ActiveSheet.Shapes("ComboBox1").ListFillRange = "A1:A10"
答案 1 :(得分: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中,两条评论的行似乎不起作用。希望有帮助吗?