Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Run a macro by sellecting a cell

Is there a way to initiate a macro by simply sellecting a cell.

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
'IF' Macro to insert cell contents to alternate cell if cell not e Gryndar Excel Worksheet Functions 6 December 20th 08 05:02 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM
Sellecting text with same format. Rick >. Excel Discussion (Misc queries) 1 July 21st 06 04:03 PM
macro to run a separate macro dependent on value in cell scottwilsonx[_13_] Excel Programming 3 July 26th 04 02:30 PM
Question: Cell formula or macro to write result of one cell to another cell Frederik Romanov Excel Programming 1 July 8th 03 03:03 PM


All times are GMT +1. The time now is 02:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"