Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Non-Intersect Function

I know I can use the Intersect function to return the address where two
ranges intersect. The code below will equal N2:BE2 as this is where the
ranges overlap.

InterectString = Intersect(Range("N2:BE2"), Range("N2:BF2")).Address

Is there a way to return the portion of the range where they do not
intersect (i.e. BF2).

Thanks EM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default Non-Intersect Function

Hi Excel Monkey,

See the archive thread:

algorithm to INVERT a multiarea selection ?
http://tinyurl.com/5gqu29




---
Regards.
Norman


"ExcelMonkey" wrote in message
...
I know I can use the Intersect function to return the address where two
ranges intersect. The code below will equal N2:BE2 as this is where the
ranges overlap.

InterectString = Intersect(Range("N2:BE2"), Range("N2:BF2")).Address

Is there a way to return the portion of the range where they do not
intersect (i.e. BF2).

Thanks EM


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Non-Intersect Function

How about:

Sub NoIntersectionFor()

Dim rng1 As Range, rng2 As Range
Dim rngNoIsect As Range, cell As Range
Set rng1 = Range("N2:BE2")
Set rng2 = Range("N2:BF2")

For Each cell In rng1.Cells
If Intersect(cell, rng2) Is Nothing Then
If rngNoIsect Is Nothing Then
Set rngNoIsect = cell
Else
Set rngNoIsect = Union(rngNoIsect, cell)
End If
End If
Next

For Each cell In rng2.Cells
If Intersect(cell, rng1) Is Nothing Then
If rngNoIsect Is Nothing Then
Set rngNoIsect = cell
Else
Set rngNoIsect = Union(rngNoIsect, cell)
End If
End If
Next

If Not rngNoIsect Is Nothing Then
MsgBox "No overlap for: " & rngNoIsect.Address
End If


End Sub

--
Tim Zych
www.higherdata.com
Compare data in workbooks and find differences with Workbook Compare
A free, powerful, flexible Excel utility

"ExcelMonkey" wrote in message
...
I know I can use the Intersect function to return the address where two
ranges intersect. The code below will equal N2:BE2 as this is where the
ranges overlap.

InterectString = Intersect(Range("N2:BE2"), Range("N2:BF2")).Address

Is there a way to return the portion of the range where they do not
intersect (i.e. BF2).

Thanks EM



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Non-Intersect Function

Yes this seems to work Tim - Thanks again.

EM

"Tim Zych" wrote:

How about:

Sub NoIntersectionFor()

Dim rng1 As Range, rng2 As Range
Dim rngNoIsect As Range, cell As Range
Set rng1 = Range("N2:BE2")
Set rng2 = Range("N2:BF2")

For Each cell In rng1.Cells
If Intersect(cell, rng2) Is Nothing Then
If rngNoIsect Is Nothing Then
Set rngNoIsect = cell
Else
Set rngNoIsect = Union(rngNoIsect, cell)
End If
End If
Next

For Each cell In rng2.Cells
If Intersect(cell, rng1) Is Nothing Then
If rngNoIsect Is Nothing Then
Set rngNoIsect = cell
Else
Set rngNoIsect = Union(rngNoIsect, cell)
End If
End If
Next

If Not rngNoIsect Is Nothing Then
MsgBox "No overlap for: " & rngNoIsect.Address
End If


End Sub

--
Tim Zych
www.higherdata.com
Compare data in workbooks and find differences with Workbook Compare
A free, powerful, flexible Excel utility

"ExcelMonkey" wrote in message
...
I know I can use the Intersect function to return the address where two
ranges intersect. The code below will equal N2:BE2 as this is where the
ranges overlap.

InterectString = Intersect(Range("N2:BE2"), Range("N2:BF2")).Address

Is there a way to return the portion of the range where they do not
intersect (i.e. BF2).

Thanks EM




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 Indirect Function to Intersect 2 Named Ranges Hokievandal Excel Programming 4 August 28th 07 07:51 PM
Intersect Function Problem [email protected] Excel Programming 5 September 20th 06 09:15 PM
intersect function problem pumpbhoy Excel Programming 2 February 16th 05 08:19 AM
how to get the intersect cell data out using vba or function mango Excel Worksheet Functions 1 December 30th 04 09:46 AM
Opposite of Intersect function - an example DataFreakFromUtah Excel Programming 1 September 17th 04 11:30 PM


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