MrExcel Publishing
Your One Stop for Excel Tips & Solutions

VB Code For ComboBox's

Posted by Damien on June 21, 2001 11:44 PM

I need to know how to add an item to a combobox list form an input box or the like with a macro ie vb code
Any One?

Posted by Malc on June 22, 2001 1:13 AM

Sub Additem()
Userform1.combobox1.additem "New Item"
end sub

Posted by Damien on June 22, 2001 4:03 AM

thanks Malc thats not it but i got it to work anyway cheers

Posted by Tuc on June 22, 2001 6:41 AM

How about:

Dim strHolder as string
Dim strholder As String
strholder = InputBox("Your Prompt Here", "Your Title Here", "Your Default Value Here")
if strholder <> "" then
' If they choose Cancel the return value is an empty string. We don't want to add an empty string to the list, do we?
ComboBox1.Additem strholder
End If