Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range)

Hi TWIMC,

What I'm trying to do is to call a sub procedure to run some code when a
user selects two or more cells that are not directly next to each other e.g.
perform sub procedure when the Target range address is like $B$34,$B$47 or
like $B$34:$B$47,$B$68, $B$34:$B$47,$B$68:$B$74 but don't perform the sub
procedure when the Target address is like $B$34:$B$42. Now I know I could use
some code like Instr(1,Targret,",") and pull each section out one by one, but
that to me that's a bit cheesy, hence is there a way to renumerate each range
within the Target ranges to see if it is made up of one or two ranges and if
so retrieve each internal range.

Any help/advice much appriciated.

TIA
KM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range)

Try this test:

Target.Areas.Count 1

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range)

Kevin,

Use this as the top of your code:

If Target.Areas.Count = 1 Then Exit Sub

HTH,
Bernie
MS Excel MVP


"Kevin McCartney" wrote in
message ...
Hi TWIMC,

What I'm trying to do is to call a sub procedure to run some code when a
user selects two or more cells that are not directly next to each other

e.g.
perform sub procedure when the Target range address is like $B$34,$B$47 or
like $B$34:$B$47,$B$68, $B$34:$B$47,$B$68:$B$74 but don't perform the sub
procedure when the Target address is like $B$34:$B$42. Now I know I could

use
some code like Instr(1,Targret,",") and pull each section out one by one,

but
that to me that's a bit cheesy, hence is there a way to renumerate each

range
within the Target ranges to see if it is made up of one or two ranges and

if
so retrieve each internal range.

Any help/advice much appriciated.

TIA
KM



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range)

Cheers, to the both of you.
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
ByVal Target As Range monir Excel Programming 4 April 12th 05 04:37 PM
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Arturo Excel Programming 2 January 7th 05 06:59 PM
How find if target is object in Worksheet_Change (ByVal Target As.. ?) Gunnar Johansson Excel Programming 3 July 1st 04 09:25 PM
what does (ByVal Target As Range) mean Zygoid[_7_] Excel Programming 6 January 31st 04 05:08 PM
Many Sub Worksheet_Change(ByVal Target As Range) In One Worksheet MathewPBennett Excel Programming 4 December 24th 03 01:01 PM


All times are GMT +1. The time now is 10:52 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"