Solved

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

Posted on 2011-09-07
5
231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

627 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