Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 320
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 320
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
how to use selectionchange instead of doubleclick event? ghost Excel Discussion (Misc queries) 0 December 24th 08 05:00 AM
SelectionChange event Kate Excel Programming 2 December 22nd 05 06:03 PM
SelectionChange event Hayeso Excel Programming 2 July 1st 05 03:07 PM
SelectionChange event Stefi Excel Programming 2 October 28th 04 01:26 PM
SelectionChange Event Squid[_3_] Excel Programming 5 February 11th 04 01:57 PM


All times are GMT +1. The time now is 03:08 AM.

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"