Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run a macro by sellecting a cell
Is there a way to initiate a macro by simply sellecting a cell.
Thank you |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run a macro by sellecting a cell
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- looper wrote: Is there a way to initiate a macro by simply sellecting a cell. Thank you |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run a macro by sellecting a cell
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 JW wrote: 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- looper wrote: Is there a way to initiate a macro by simply sellecting a cell. Thank you |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run a macro by sellecting a cell
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
'IF' Macro to insert cell contents to alternate cell if cell not e | Excel Worksheet Functions | |||
using a cell value to control a counter inside a macro and displaying macro value | Excel Worksheet Functions | |||
Sellecting text with same format. | Excel Discussion (Misc queries) | |||
macro to run a separate macro dependent on value in cell | Excel Programming | |||
Question: Cell formula or macro to write result of one cell to another cell | Excel Programming |