combobox vb app in excel

i added a combobox in excel and now trying to add item to that combobox from the macro but i can't. here is what i got. using excel 2007 to write the macro but i will need to save it for 97-2003 office. also do i need to add any references? thank you

Private Sub Workbook_Open()
        combobox1.Clear
        combobox1.AddItem "Credit Card"
        combobox1.AddItem "Check"
End Sub

Open in new window

StewSupportAsked:
Who is Participating?
 
Saurabh Singh TeotiaConnect With a Mentor Commented:
Here is more about how to add values in combox...
http://www.contextures.com/xlDataVal10.html
Saurabh...
0
 
Saurabh Singh TeotiaCommented:
This would work in 97-2003 as well so it wont be an issue...rather you can do this...
Saurabh...

Private Sub Workbook_Open()
With combobox1
.Clear
.AddItem "Credit Card"
.AddItem "Check"
End With
End Sub

Open in new window

0
 
StewSupportAuthor Commented:
yeah i did that before and when open my workbook nothing was on the list.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
Saurabh Singh TeotiaCommented:
Ahh..are you using a loop statement arrond it..?? Because if you are then it will look like this...
 

combobox1.Clear
' your loop statement
With combobox1
.AddItem "Credit Card"
.AddItem "Check"
End With
'end loop here
 
End Sub

Open in new window

0
 
StewSupportAuthor Commented:
no there's no loop or anything the first post you have is what i'm trying to do but it just wouldn't display. i was wondering if i am missing so reference here.
0
 
Saurabh Singh TeotiaCommented:
Well did you check the link which i gave to you..it tells you how to fill the combox ..if you can update your sample file along with the question can help you in doing the same...
0
 
StewSupportAuthor Commented:
your article is only good if you are manually create dropdownlist or combobox on the front end not from the code. i know how to do that on the front end.
0
 
Rory ArchibaldCommented:
Where is combobox1 located?
0
 
Rory ArchibaldCommented:
Also, is that code in the ThisWorkbook module of your workbook? It needs to be.
0
 
Saurabh Singh TeotiaCommented:
Well if you go further down you would find the code to do that...and thats why i asked your sample data so that i can help you in designing the same for you...
0
 
clarkscottCommented:
I think you have to designate a SHEET.  Your code opens the workbook but doesn't state what sheet to activate.

Scott C
0
 
StewSupportAuthor Commented:
not really a solution i used something else instead.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.