+ Reply to Thread
Results 1 to 5 of 5

Can you use a Range $N$xx:$Q$xx in Target.Address?

  1. #1
    CRayF
    Guest

    Can you use a Range $N$xx:$Q$xx in Target.Address?

    This works:
    If Target.Address = "$N$" & j Or _
    Target.Address = "$O$" & j Or _
    Target.Address = "$P$" & j Or _
    Target.Address = "$Q$" & j Then

    Wouldn't this work (or do I jsut have the syntax down wrong)?
    If Target.Address = "$N$" & j & ":$Q$" & j Then


  2. #2
    Tom Ogilvy
    Guest

    Re: Can you use a Range $N$xx:$Q$xx in Target.Address?

    no. if you want to test if the target falls in a range

    if not intersect(Target, Range("N" & j & ":Q" & j)) then


    --
    Regards,
    Tom Ogilvy



    "CRayF" <[email protected]> wrote in message
    news:[email protected]...
    > This works:
    > If Target.Address = "$N$" & j Or _
    > Target.Address = "$O$" & j Or _
    > Target.Address = "$P$" & j Or _
    > Target.Address = "$Q$" & j Then
    >
    > Wouldn't this work (or do I jsut have the syntax down wrong)?
    > If Target.Address = "$N$" & j & ":$Q$" & j Then
    >




  3. #3
    CRayF
    Guest

    Re: Can you use a Range $N$xx:$Q$xx in Target.Address?

    I currently have this code and all works fine. I was trying to rewrite the 4
    Target statements into one. I tried using this line:
    If Not Intersect(Target, Range("N" & j & ":Q" & j)) Then
    Instead of the 4 Target statements below but nothing happens?
    Can the above statement not be used like this?

    --------------------------
    src = srcProgramDataInputWs.Range("B3").Value
    i = 3
    j = 3
    Do Until src = ""

    If Not Intersect(Target, Range("N" & j & ":Q" & j)) Then
    ' If Target.Address = "$N$" & j Or _
    ' Target.Address = "$O$" & j Or _
    ' Target.Address = "$P$" & j Or _
    ' Target.Address = "$Q$" & j Then

    ActiveWindow.ScrollRow = Target.Row 'Scoll to top of screen
    End If
    j = j + 12 'add for next set of (12) rows
    'Look for the existence of a Race number (no race number will end loop)
    src = srcProgramDataInputWs.Cells(i, 2).Value
    Loop
    -----------------------------

    "Tom Ogilvy" wrote:

    > no. if you want to test if the target falls in a range
    >
    > if not intersect(Target, Range("N" & j & ":Q" & j)) then
    > --
    > Regards,
    > Tom Ogilvy


  4. #4
    Tom Ogilvy
    Guest

    Re: Can you use a Range $N$xx:$Q$xx in Target.Address?

    It should be:

    if not intersect(Target, Range("N" & j & ":Q" & j)) is nothing then

    --
    Regards,
    Tom Ogilvy


    "CRayF" <[email protected]> wrote in message
    news:[email protected]...
    > I currently have this code and all works fine. I was trying to rewrite the

    4
    > Target statements into one. I tried using this line:
    > If Not Intersect(Target, Range("N" & j & ":Q" & j)) Then
    > Instead of the 4 Target statements below but nothing happens?
    > Can the above statement not be used like this?
    >
    > --------------------------
    > src = srcProgramDataInputWs.Range("B3").Value
    > i = 3
    > j = 3
    > Do Until src = ""
    >
    > If Not Intersect(Target, Range("N" & j & ":Q" & j)) Then
    > ' If Target.Address = "$N$" & j Or _
    > ' Target.Address = "$O$" & j Or _
    > ' Target.Address = "$P$" & j Or _
    > ' Target.Address = "$Q$" & j Then
    >
    > ActiveWindow.ScrollRow = Target.Row 'Scoll to top of screen
    > End If
    > j = j + 12 'add for next set of (12) rows
    > 'Look for the existence of a Race number (no race number will end

    loop)
    > src = srcProgramDataInputWs.Cells(i, 2).Value
    > Loop
    > -----------------------------
    >
    > "Tom Ogilvy" wrote:
    >
    > > no. if you want to test if the target falls in a range
    > >
    > > if not intersect(Target, Range("N" & j & ":Q" & j)) then
    > > --
    > > Regards,
    > > Tom Ogilvy




  5. #5
    CRayF
    Guest

    Re: Can you use a Range $N$xx:$Q$xx in Target.Address?

    Very Good...

    "Tom Ogilvy" wrote:

    > It should be:
    >
    > if not intersect(Target, Range("N" & j & ":Q" & j)) is nothing then
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "CRayF" <[email protected]> wrote in message
    > news:[email protected]...
    > > I currently have this code and all works fine. I was trying to rewrite the

    > 4
    > > Target statements into one. I tried using this line:
    > > If Not Intersect(Target, Range("N" & j & ":Q" & j)) Then
    > > Instead of the 4 Target statements below but nothing happens?
    > > Can the above statement not be used like this?
    > >
    > > --------------------------
    > > src = srcProgramDataInputWs.Range("B3").Value
    > > i = 3
    > > j = 3
    > > Do Until src = ""
    > >
    > > If Not Intersect(Target, Range("N" & j & ":Q" & j)) Then
    > > ' If Target.Address = "$N$" & j Or _
    > > ' Target.Address = "$O$" & j Or _
    > > ' Target.Address = "$P$" & j Or _
    > > ' Target.Address = "$Q$" & j Then
    > >
    > > ActiveWindow.ScrollRow = Target.Row 'Scoll to top of screen
    > > End If
    > > j = j + 12 'add for next set of (12) rows
    > > 'Look for the existence of a Race number (no race number will end

    > loop)
    > > src = srcProgramDataInputWs.Cells(i, 2).Value
    > > Loop
    > > -----------------------------
    > >
    > > "Tom Ogilvy" wrote:
    > >
    > > > no. if you want to test if the target falls in a range
    > > >
    > > > if not intersect(Target, Range("N" & j & ":Q" & j)) then
    > > > --
    > > > Regards,
    > > > Tom Ogilvy

    >
    >
    >


+ 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