+ Reply to Thread
Results 1 to 4 of 4

Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range)

  1. #1
    Kevin McCartney
    Guest

    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. #2
    P Sitaram
    Guest

    Re: Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range)

    Try this test:

    Target.Areas.Count > 1


  3. #3
    Bernie Deitrick
    Guest

    Re: 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" <[email protected]> wrote in
    message news:[email protected]...
    > 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. #4
    Kevin McCartney
    Guest

    RE: Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range)

    Cheers, to the both of you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1