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

Excel 2007: Testing for ComboBox1 versus ComboBox2

I have the folloing code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    MsgBox "combo change"
End Sub

displaying a single message box for a change to either ComboBox on the page.

Questions:

1) How do I make a unique message (event) for each ComboBox?
2) How do I make this code apply to all pages in the entier Excel spreasheet?

Thanks.
0
newbieweb
Asked:
newbieweb
  • 4
  • 2
3 Solutions
 
jppintoCommented:
You can try using and Handler like the example provided by rorya on this question here:

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_27181728.html

jppinto
0
 
Rory ArchibaldCommented:
FYI, the SelectionChange event responds to you selecting a different cell, not to a change in the value of anything.
0
 
newbiewebSr. Software EngineerAuthor Commented:
> FYI, the SelectionChange event responds to you selecting a different cell, not to a change in the value of anything.

Right. I was hoping for some way to parse the input parameter to the event and be able to then call two different sections of the code, based on (for example) the row/column where the control is located.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
newbiewebSr. Software EngineerAuthor Commented:
I downloade the test spreadsheet from rorya's link, but can not et the message box to open. I enabled Macro's and also checked "Trust access to the VBA project object model".  But no success. Nothing opens when I click the checkboxes.

So I am a bit lost here...

0
 
newbiewebSr. Software EngineerAuthor Commented:
I mean is there a way to extract the information out of the parameter Target?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    MsgBox "combo change to Worksheet 2"
End Sub

I'd like to say

MsgBox "combo change to Worksheet 2 by " + Target.Name
0
 
Rory ArchibaldCommented:
The Target argument is the range you just selected. Not sure what that is going to tell you. I think you really want the Change event instead, where the Target argument is the changed range.
0
 
newbiewebSr. Software EngineerAuthor Commented:
Thanks. I think I was confused. Peace.
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.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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