Got any Excel Questions? Free Excel Help
Adding values to a Combobox
Egad couldn’t find the right VBA syntax to change the properties of a ComboBox on a worksheet. (i.e. change the listfillrange). He wanted this to occur via VBA after other macros have chugged.
He solved the post himself with the following VBA code: -
ActiveSheet.Shapes("ComboBox3").Select
Selection.ListFillRange = "k1:k10"
bnix then provided another couple of methods:-
With ComboBox1
.AddItem "This"
.AddItem "Is"
.AddItem "A"
.AddItem "Test"
End With
If you are using a range you would need to set up some type of loop, here is one that I would use in a Userform;
Private Sub UserForm_Initialize()
With cboRD
For Row = 2 To 10 'Each cell in the range
.AddItem Sheets("MenuSheet").Cells(Row, 11)
Next Row
End With
With cboBM
For Row = 1 To 75
.AddItem Sheets("MenuSheet").Cells(Row, 8)
Next Row
End With
With cboBr
For Row = 1 To 75
.AddItem Sheets("MenuSheet").Cells(Row, 7)
Next Row
End With
End Sub
See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets.
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.
i don't want to do my essay