• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

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

0
StewSupport
Asked:
StewSupport
  • 5
  • 4
  • 2
  • +1
1 Solution
 
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
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Saurabh Singh TeotiaCommented:
Here is more about how to add values in combox...
http://www.contextures.com/xlDataVal10.html
Saurabh...
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now