我如何分配这个combobox(名称= Combobox1)的名称,并将其范围到一个固定的位置(单元格C4)?

With ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1",Link:=False, DisplayAsIcon:=False, Left:=50, Top:=80, Width:=100, Height:=15) With .Object .AddItem "Yes" .AddItem "No" End With End With 

我怎样才能分配一个名称并确定它的位置(基于上面的代码)?

试试这个代码:

 Sub Test() Dim Rng As Range: Set Rng = Range("C4") With ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1", Link:=False, DisplayAsIcon:=False, Left:=Rng.Left, Top:=Rng.Top, Width:=100, Height:=15) .Name = "Combobox_Name" ' change the name With .Object .AddItem "Yes" .AddItem "No" End With End With End Sub 

尝试这个:

 Sub Test() Dim ws As Worksheet Dim ComboBx1 As OLEObject Set ws = ActiveSheet Set ComboBx1 = ws.OLEObjects.Add("Forms.ComboBox.1") With ComboBx1 .Left = ws.Range("C4").Left .Top = ws.Range("C4").Top .Name = "WateverYouWant" .Width = "150" End With With ws.OLEObjects("WateverYouWant").Object .AddItem "Yes" .AddItem "No" End With End Sub