Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Return intesected range

I am using Office 2003 on Windows XP.

My code dynamically returns certain contiguous columns and certain
continguous rows, say "C:E" and "5:10" for example, in two different
variables as string addresses.

I need to return the address of the intersection of these two ranges: C5:E10
Is it possible to do this without parsing the range addresses and without
actually changing the user's current selection? If so, could someone please
post a one or two line solution? I've been trying to use the "Intersect"
method without success.

Thanks much in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Return intesected range

strAddress = Intersect(Range(Var1),Range(Var2)).Address(False,F alse)

HTH,
Bernie
MS Excel MVP


"XP" wrote in message
...
I am using Office 2003 on Windows XP.

My code dynamically returns certain contiguous columns and certain
continguous rows, say "C:E" and "5:10" for example, in two different
variables as string addresses.

I need to return the address of the intersection of these two ranges: C5:E10
Is it possible to do this without parsing the range addresses and without
actually changing the user's current selection? If so, could someone please
post a one or two line solution? I've been trying to use the "Intersect"
method without success.

Thanks much in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Return intesected range

Sub test()
Dim iRange As Range
Set iRange = Intersect(Range("C:E"), Range("5:10"))
Debug.Print iRange.Address
End Sub

HTH
--
AP

"XP" a écrit dans le message de
...
I am using Office 2003 on Windows XP.

My code dynamically returns certain contiguous columns and certain
continguous rows, say "C:E" and "5:10" for example, in two different
variables as string addresses.

I need to return the address of the intersection of these two ranges:

C5:E10
Is it possible to do this without parsing the range addresses and without
actually changing the user's current selection? If so, could someone

please
post a one or two line solution? I've been trying to use the "Intersect"
method without success.

Thanks much in advance.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Return intesected range

Bernie,

If I manually selected, say Rows 4 and 5 and, using the Control key, columnd
C and D, how would I trap the intersection of these two ranges (e.g. C4:D5) ?

Thanks in advance

Pete

"Bernie Deitrick" wrote:

strAddress = Intersect(Range(Var1),Range(Var2)).Address(False,F alse)

HTH,
Bernie
MS Excel MVP


"XP" wrote in message
...
I am using Office 2003 on Windows XP.

My code dynamically returns certain contiguous columns and certain
continguous rows, say "C:E" and "5:10" for example, in two different
variables as string addresses.

I need to return the address of the intersection of these two ranges: C5:E10
Is it possible to do this without parsing the range addresses and without
actually changing the user's current selection? If so, could someone please
post a one or two line solution? I've been trying to use the "Intersect"
method without success.

Thanks much in advance.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Return intesected range

Peter,

Sub Intersect2()
Dim myR As Range

If Selection.Areas.Count < 2 Then
MsgBox "You must select two areas"
Exit Sub
End If

Set myR = Intersect(Selection.Areas(1), Selection.Areas(2))

MsgBox myR.Address(False, False)

End Sub

HTH,
Bernie
MS Excel MVP

"Peter Rooney" wrote in message
...
Bernie,

If I manually selected, say Rows 4 and 5 and, using the Control key,
columnd
C and D, how would I trap the intersection of these two ranges (e.g.
C4:D5) ?

Thanks in advance

Pete

"Bernie Deitrick" wrote:

strAddress = Intersect(Range(Var1),Range(Var2)).Address(False,F alse)

HTH,
Bernie
MS Excel MVP


"XP" wrote in message
...
I am using Office 2003 on Windows XP.

My code dynamically returns certain contiguous columns and certain
continguous rows, say "C:E" and "5:10" for example, in two different
variables as string addresses.

I need to return the address of the intersection of these two ranges:
C5:E10
Is it possible to do this without parsing the range addresses and
without
actually changing the user's current selection? If so, could someone
please
post a one or two line solution? I've been trying to use the
"Intersect"
method without success.

Thanks much in advance.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Return intesected range

Bernie,

Just the job.

Thanks a lot! :-)

Pete



"Bernie Deitrick" wrote:

Peter,

Sub Intersect2()
Dim myR As Range

If Selection.Areas.Count < 2 Then
MsgBox "You must select two areas"
Exit Sub
End If

Set myR = Intersect(Selection.Areas(1), Selection.Areas(2))

MsgBox myR.Address(False, False)

End Sub

HTH,
Bernie
MS Excel MVP

"Peter Rooney" wrote in message
...
Bernie,

If I manually selected, say Rows 4 and 5 and, using the Control key,
columnd
C and D, how would I trap the intersection of these two ranges (e.g.
C4:D5) ?

Thanks in advance

Pete

"Bernie Deitrick" wrote:

strAddress = Intersect(Range(Var1),Range(Var2)).Address(False,F alse)

HTH,
Bernie
MS Excel MVP


"XP" wrote in message
...
I am using Office 2003 on Windows XP.

My code dynamically returns certain contiguous columns and certain
continguous rows, say "C:E" and "5:10" for example, in two different
variables as string addresses.

I need to return the address of the intersection of these two ranges:
C5:E10
Is it possible to do this without parsing the range addresses and
without
actually changing the user's current selection? If so, could someone
please
post a one or two line solution? I've been trying to use the
"Intersect"
method without success.

Thanks much in advance.






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
Return date if in range, else return blank LisaL Excel Worksheet Functions 1 July 22nd 09 03:23 PM
Return Range Address from Active Range ExcelMonkey Excel Programming 1 February 10th 06 12:00 PM
return min. of range except 0 Melissa Excel Discussion (Misc queries) 2 January 11th 06 12:14 PM
I need information from a cell intesected by a column and row. Danny Excel Worksheet Functions 5 June 27th 05 04:04 AM
How do I return the name of a Range? **Archie** Excel Programming 1 November 13th 03 11:31 PM


All times are GMT +1. The time now is 02:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"