Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default 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






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
Using Target.Address in Excel 98 Noemi Excel Discussion (Misc queries) 2 November 7th 05 01:36 PM
Target.Address Doesn't Work in Excel 97? JK Excel Programming 3 September 27th 05 04:15 AM
Target.Address syntax Coolboy55 Excel Worksheet Functions 3 August 23rd 05 12:23 AM
Ranges:Target in Worksheet_SelectionChange(ByVal Target As Range) Kevin McCartney Excel Programming 3 April 15th 05 01:51 PM
target address Mark Kubicki Excel Programming 2 October 31st 03 04:19 PM


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