We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

combobox vb app in excel

Medium Priority
314 Views
Last Modified: 2012-05-06
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

Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2015

Commented:
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

Author

Commented:
yeah i did that before and when open my workbook nothing was on the list.
CERTIFIED EXPERT
Top Expert 2015

Commented:
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

CERTIFIED EXPERT
Top Expert 2015
Commented:
Here is more about how to add values in combox...
http://www.contextures.com/xlDataVal10.html
Saurabh...

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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.
CERTIFIED EXPERT
Top Expert 2015

Commented:
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...

Author

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.
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011

Commented:
Where is combobox1 located?
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011

Commented:
Also, is that code in the ThisWorkbook module of your workbook? It needs to be.
CERTIFIED EXPERT
Top Expert 2015

Commented:
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...
CERTIFIED EXPERT

Commented:
I think you have to designate a SHEET.  Your code opens the workbook but doesn't state what sheet to activate.

Scott C

Author

Commented:
not really a solution i used something else instead.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.