Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
SelectionChange Event
I am trying to use the worksheet_selectionchange event and it doesn't seem to
be doing anything. I would like to call a sub routine when the user clicks on cell "a18" I am trying just to see if I can get the event to trigger and no matter what I do nothing happens right now I tried this: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "A18" Then MsgBox "hello" End If End Sub This is in the worksheet that I want it to run for Do I have to turn on anything for this event to work? Am I missing something? Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
SelectionChange Event
The Target.Address has the "$" in it. Change your code to:
If target.Address = "$A$18" Then... "James" wrote in message ... I am trying to use the worksheet_selectionchange event and it doesn't seem to be doing anything. I would like to call a sub routine when the user clicks on cell "a18" I am trying just to see if I can get the event to trigger and no matter what I do nothing happens right now I tried this: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "A18" Then MsgBox "hello" End If End Sub This is in the worksheet that I want it to run for Do I have to turn on anything for this event to work? Am I missing something? Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
SelectionChange Event
To follow up...
Or, if you want to use addresses without the $ signs, then do it this way... If Target.Address(0, 0) = "A18" Then -- Rick (MVP - Excel) "Bob Umlas" wrote in message ... The Target.Address has the "$" in it. Change your code to: If target.Address = "$A$18" Then... "James" wrote in message ... I am trying to use the worksheet_selectionchange event and it doesn't seem to be doing anything. I would like to call a sub routine when the user clicks on cell "a18" I am trying just to see if I can get the event to trigger and no matter what I do nothing happens right now I tried this: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "A18" Then MsgBox "hello" End If End Sub This is in the worksheet that I want it to run for Do I have to turn on anything for this event to work? Am I missing something? Thanks |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
SelectionChange Event
Yeah, but that takes 3 keystrokes more and the "$" takes 2!
:-) "Rick Rothstein" wrote in message ... To follow up... Or, if you want to use addresses without the $ signs, then do it this way... If Target.Address(0, 0) = "A18" Then -- Rick (MVP - Excel) "Bob Umlas" wrote in message ... The Target.Address has the "$" in it. Change your code to: If target.Address = "$A$18" Then... "James" wrote in message ... I am trying to use the worksheet_selectionchange event and it doesn't seem to be doing anything. I would like to call a sub routine when the user clicks on cell "a18" I am trying just to see if I can get the event to trigger and no matter what I do nothing happens right now I tried this: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "A18" Then MsgBox "hello" End If End Sub This is in the worksheet that I want it to run for Do I have to turn on anything for this event to work? Am I missing something? Thanks |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
SelectionChange Event
Then I'm glad I didn't suggest using this...
If Target.Address = Range("A18").Address Then <g -- Rick (MVP - Excel) "Bob Umlas" wrote in message ... Yeah, but that takes 3 keystrokes more and the "$" takes 2! :-) "Rick Rothstein" wrote in message ... To follow up... Or, if you want to use addresses without the $ signs, then do it this way... If Target.Address(0, 0) = "A18" Then -- Rick (MVP - Excel) "Bob Umlas" wrote in message ... The Target.Address has the "$" in it. Change your code to: If target.Address = "$A$18" Then... "James" wrote in message ... I am trying to use the worksheet_selectionchange event and it doesn't seem to be doing anything. I would like to call a sub routine when the user clicks on cell "a18" I am trying just to see if I can get the event to trigger and no matter what I do nothing happens right now I tried this: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "A18" Then MsgBox "hello" End If End Sub This is in the worksheet that I want it to run for Do I have to turn on anything for this event to work? Am I missing something? Thanks |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
SelectionChange Event
Another ...
Private Sub Worksheet_SelectionChange(ByVal Target As Range) if target.cells.count 1 then exit sub 'single cell at a time end if if intersect(target, me.range("A18")) is nothing then exit sub end if msgbox "hi" End sub I find that this syntax is easier to modify if I have to monitor other ranges: if intersect(target, me.range("A18:B22,D:E,G18,L98")) is nothing then James wrote: I am trying to use the worksheet_selectionchange event and it doesn't seem to be doing anything. I would like to call a sub routine when the user clicks on cell "a18" I am trying just to see if I can get the event to trigger and no matter what I do nothing happens right now I tried this: Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "A18" Then MsgBox "hello" End If End Sub This is in the worksheet that I want it to run for Do I have to turn on anything for this event to work? Am I missing something? Thanks -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to use selectionchange instead of doubleclick event? | Excel Discussion (Misc queries) | |||
SelectionChange event | Excel Programming | |||
SelectionChange event | Excel Programming | |||
SelectionChange event | Excel Programming | |||
SelectionChange Event | Excel Programming |