Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default opposite of intersect

hello
In Excel VBA, I've got a range from wich I would like to "except a cell"

example: R = A:A
and I would like R=A:A except A3
this means R = union(A1:A2;A4:A65536)

in the general way, how is it possible ?
I know union, I know intersect,
how to do this one... ?



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default opposite of intersect

You cannot remove a cell from a range object as far as I know. All you can
do is build a new range based on another but not including the excluded
cell.

Here is an example of one way to do this. I'm not sure it's practical for
such a large range as in your example:

Sub TestIt()
AntiRange(Range("A1:F100"), Range("B1:B10")).Select
End Sub

Function AntiRange(BigRg As Range, ExcludeRg As Range) As Range
Dim NewRg As Range, CurrCell As Range
For Each CurrCell In BigRg.Cells
If Intersect(CurrCell, ExcludeRg) Is Nothing Then
If NewRg Is Nothing Then
Set NewRg = CurrCell
Else
Set NewRg = Union(NewRg, CurrCell)
End If
End If
Next
Set AntiRange = NewRg
End Function

--
Jim Rech
Excel MVP
"David C." wrote in message
...
| hello
| In Excel VBA, I've got a range from wich I would like to "except a cell"
|
| example: R = A:A
| and I would like R=A:A except A3
| this means R = union(A1:A2;A4:A65536)
|
| in the general way, how is it possible ?
| I know union, I know intersect,
| how to do this one... ?
|
|
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default opposite of intersect

thank you, i also think it's not great for big ranges

for big one,
maybe working on row and column of the exctracted cell

well, there's no except build-in function, that's the answer...


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
Intersect Line GoodTrouble Charts and Charting in Excel 4 January 29th 08 05:08 PM
Intersect with decimal Nicke Excel Programming 0 November 20th 03 02:02 PM
Dont intersect JethroUK© Excel Programming 6 November 16th 03 08:40 PM
Intersect Formula??? scrabtree[_2_] Excel Programming 3 October 15th 03 08:30 PM
Help with If Not Intersect derek Excel Programming 6 July 11th 03 04:39 PM


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