Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Gary''s Student wrote...
.... the only time the "brute force" approach is necessary is if either of the ranges have disjoint cells. .... No, you could iterate through all areas in each range A (larger) and B (smaller). First, you'd need to check that each area in B is contained in A as a whole, so state = True For Each r In B.Areas state = state And (Intersection(A, r).Cells.Count = r.Cells.Count) Next r Then you'd need to iterate through each area in A, then iterating through each area in B, finding the complement of the intersection of the current areas of A and B in the current area of A, taking the intersection of the complements of all the areas in B in the current area in A, then taking the union of all these intersections. Messy. Set C = Nothing For i = 1 To A.Areas.Count Set D = Nothing For j = 1 To B.Areas.Count Set t = rc(A.Areas(i), Intersect(A.Areas(i), B.Areas(j))) '## my earlier rc function ## If Not t Is Nothing Then If D Is Nothing Then Set D = t Else Set D = Intersection(D, t) Next j If Not D Is Nothing Then If C Is Nothing Then Set C = D Else Set C = Union(C, D) Next i I thought this was overkill for the OP's problem. Also, this doesn't ensure the areas in C are mutually disjoint. OK for clearing the complement of B in A, but not OK for calculations. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Addin:Setting the range to the Excel.Range object range prop | Excel Worksheet Functions | |||
Sum a range but exclude and negative values | Excel Worksheet Functions | |||
Duplicate Range Names by worksheet | Excel Discussion (Misc queries) | |||
Need to exclude certain cells in a range | Excel Worksheet Functions | |||
Array to named range conversion... | Excel Discussion (Misc queries) |