Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheet_Selectionchange for range


Hi

I hve this code:


Code:
--------------------
Private sub Worksheet_Selectionchange(ByVal Target As Range)

if target.address="$B$4" then
msgbox"Hello"
end if
end sub

--------------------


But I want this to work for a range of cells on the sheet, i.e.:


Code:
--------------------
Private sub Worksheet_Selectionchange(ByVal Target As Range)

if target.RANGE="A2:E4" then
msgbox "Hello"
end if
end sub



--------------------


Ideas welcome

tx


--
tx12345
------------------------------------------------------------------------
tx12345's Profile: http://www.excelforum.com/member.php...o&userid=24776
View this thread: http://www.excelforum.com/showthread...hreadid=571940

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Worksheet_Selectionchange for range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("A2:E4")) Is Nothing Then
MsgBox "Out of Range"
Else
MsgBox "In Range"
End If
End Sub

HTH

Charles Chickering

tx12345 wrote:
Hi

I hve this code:


Code:
--------------------
Private sub Worksheet_Selectionchange(ByVal Target As Range)

if target.address="$B$4" then
msgbox"Hello"
end if
end sub

--------------------


But I want this to work for a range of cells on the sheet, i.e.:


Code:
--------------------
Private sub Worksheet_Selectionchange(ByVal Target As Range)

if target.RANGE="A2:E4" then
msgbox "Hello"
end if
end sub



--------------------


Ideas welcome

tx


--
tx12345
------------------------------------------------------------------------
tx12345's Profile: http://www.excelforum.com/member.php...o&userid=24776
View this thread: http://www.excelforum.com/showthread...hreadid=571940


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Worksheet_Selectionchange for range

Private sub Worksheet_Selectionchange(ByVal Target As Range)

if not intersect(target, Range("A2:E4")) is nothing then
msgbox"Hello"
end if
end sub

--
HTH...

Jim Thomlinson


"tx12345" wrote:


Hi

I hve this code:


Code:
--------------------
Private sub Worksheet_Selectionchange(ByVal Target As Range)

if target.address="$B$4" then
msgbox"Hello"
end if
end sub

--------------------


But I want this to work for a range of cells on the sheet, i.e.:


Code:
--------------------
Private sub Worksheet_Selectionchange(ByVal Target As Range)

if target.RANGE="A2:E4" then
msgbox "Hello"
end if
end sub



--------------------


Ideas welcome

tx


--
tx12345
------------------------------------------------------------------------
tx12345's Profile: http://www.excelforum.com/member.php...o&userid=24776
View this thread: http://www.excelforum.com/showthread...hreadid=571940


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Worksheet_Selectionchange for range

Private sub Worksheet_Selectionchange(ByVal Target As Range)

if not intersect(target, RANGE("A2:E4")) is nothing then
msgbox "Hello"
end if
end sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"tx12345" wrote in
message ...

Hi

I hve this code:


Code:
--------------------
Private sub Worksheet_Selectionchange(ByVal Target As Range)

if target.address="$B$4" then
msgbox"Hello"
end if
end sub

--------------------


But I want this to work for a range of cells on the sheet, i.e.:


Code:
--------------------
Private sub Worksheet_Selectionchange(ByVal Target As Range)

if target.RANGE="A2:E4" then
msgbox "Hello"
end if
end sub



--------------------


Ideas welcome

tx


--
tx12345
------------------------------------------------------------------------
tx12345's Profile:

http://www.excelforum.com/member.php...o&userid=24776
View this thread: http://www.excelforum.com/showthread...hreadid=571940



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheet_Selectionchange for range


Thanks. Works perfectly.


t

--
tx1234
-----------------------------------------------------------------------
tx12345's Profile: http://www.excelforum.com/member.php...fo&userid=2477
View this thread: http://www.excelforum.com/showthread.php?threadid=57194

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
Worksheet_SelectionChange Gary''s Student Excel Programming 3 April 5th 06 09:46 AM
insert Worksheet_SelectionChange(ByVal Target As Range) through vba scott[_10_] Excel Programming 2 February 16th 06 02:47 PM
Worksheet_SelectionChange(ByVal Target As Range) questions Gary Keramidas[_4_] Excel Programming 2 October 2nd 05 10:31 AM
Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range) Kevin McCartney Excel Programming 3 April 15th 05 01:51 PM
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Arturo Excel Programming 2 January 7th 05 06:59 PM


All times are GMT +1. The time now is 01:17 PM.

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

About Us

"It's about Microsoft Excel"