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 |
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" wrote in message ... 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 |
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 |
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" wrote in message ... 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 |
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" wrote in message ... 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 |
Can you use a Range $N$xx:$Q$xx in Target.Address?
Yep. There is no "something" in VBA.
I find that this can be confusing if not xxx is nothing then 'do AAA else 'do BBB end if I just change it to: if xxx is nothing then 'do BBB else 'do AAA end if I have lots of code that looks like: if myobject is nothing then 'do nothing else myobject.name = "asdf" end if I find my brain hurts less. Dave wrote: On Thu, 29 Sep 2005 16:49:27 -0400, "Tom Ogilvy" wrote: Hi Tom, May I ask you a question on this reply please ? Why did you use 'If Not ....... is nothing' rather than 'If ..... is something'. Please don't get me wrong, I'm not being picky or anything, but what I'd like to know - and I guess it's something to do with the 'nothing' bit - is it because there is no opposite to 'nothing' in this intersect statement ? I hope I have made sense here - I'm trying to understand the reasoning behind the negative of nothing. Regards, Dave It should be: if not intersect(Target, Range("N" & j & ":Q" & j)) is nothing then -- Dave Peterson |
All times are GMT +1. The time now is 10:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com