Run a macro by sellecting a cell

J

JW

In the Microsoft Excel Objects folder within your VBA Project, select
the sheet that contains the cell that you want to run the macro.
Place the code in the Worksheet_SelectionChange event of that sheet.
Or, you could have the main code stored in a seperate module and
simply call it from the selectionchange event. Example:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$G$5" Then MsgBox "you click it!"
End Sub
--Or--
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
call ClickedSub
End Sub

HTH
-Jeff-
 
J

JW

oops. Made a typo. To call another sub when G5 is clicked, use:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$G$5" Then Call ClickedSub
End Sub
 
G

Guest

Jeff, thank you for the response. I think i could make it work if I were more
experienced or had a little more time. What I am trying to do is to allow
inexperienced users to select from one of 10 customers that are listed in 10
different cells. Selecting the customers sets pivot filters to show specific
info for each. This process works and I currently have text boxes with
assigned macros for each customer. This works but is very cumbersome to add
new customers. That is why i am trying to initiate from cell selection.

Thanks for the help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top