Solved

Need to open a Message Box from a ComboBox, in Excel 2007

Posted on 2011-09-07
5
219 Views
Last Modified: 2012-06-27
I am trying to write my first VBA function in Excel and do not know how to get the code associated with a given ComboBox. So I thought opening a MessageBox would at least give me confirmation that it was opening correctly.

I already know how to fill a combo box with values.

So, please explain, step by step, how to get to get a given combo box to open a Message Box when a given selection is made on the combo.

Thanks!
0
Comment
Question by:newbieweb
  • 3
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
carsRST earned 500 total points
ID: 36496632
Private Sub ComboBox1_Change()
    MsgBox "combo change"
End Sub
0
 

Author Comment

by:newbieweb
ID: 36497340
Tahanks. BUt it does not work where I put it, since that's also new to me:)

I use Excel 2007.

1) From the Developer Tab I opened Visual Basic
2) Right clicked the Worksheet
3) Pasted in the code
4) Hit Save

But nowhere do I find how to name the control ComboBox1.

What am I missing??
0
 

Author Closing Comment

by:newbieweb
ID: 36497398
Thanks!  It works!

I neded to let the form generate the full event and need to move the mouse away from the combo box for the message box to open.
0
 
LVL 16

Expert Comment

by:carsRST
ID: 36497414
In design mode, assuming you're using ActiveX, you can just double click your combobox.  That should take you to the change "event" associated with that combobox.  That's where you'll enter your msgbox line.

See the attached file.  Probably obvious but make sure to enable macros.

See the code under sheet1 msgbox.xlsm
0
 
LVL 16

Expert Comment

by:carsRST
ID: 36497419
Oh...sorry.  I guess I should have asked if you were using a form.

Thanks for the points.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now