Avatar of AL_XResearch
AL_XResearch
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Excel VBA: Nested Areas in a Range object ?

I am fairly sure this is not possible but I wanted to 'bounce it off' my fellow Excel experts to be sure.

When you have a range object that includes multiple non-contiguous ranges they are represented as child 'Area' objects of a master Range object. If you have multiple ranges which each contain multiple areas and you combine those ranges will you only get one 'level' or area objects or can each area object include multiple areas in a nested fashion ?

It appears to me, and common sense. that when a new range is created out of a union of combined ranges their multi-area reference notation is simply combined together so it appears as if you had selected all the areas in one range object. In which case it is not possible that one of more areas in a range will itself contain multiple areas.

Am I right ?
Microsoft ExcelMicrosoft ApplicationsSpreadsheets

Avatar of undefined
Last Comment
AL_XResearch

8/22/2022 - Mon
Jeff Darling

I think one way to test this is to look at some VBA with a union of some ranges that overlap.

Excel Range Union Test
Dim Area1Rng As Range
Dim Area2Rng As Range
Dim Area3Rng As Range
Dim Area4Rng As Range

Set Area1Rng = Range("Area1")
Set Area2Rng = Range("Area2")
Set Area3Rng = Range("Area3")
Set Area4Rng = Range("Area4")


For Each itm In Area1Rng
  lstRangesArea1.AddItem itm.Address
Next

For Each itm In Area2Rng
  lstRangesArea2.AddItem itm.Address
Next

For Each itm In Area3Rng
  lstRangesArea3.AddItem itm.Address
Next

For Each itm In Area4Rng
  lstRangesArea4.AddItem itm.Address
Next

Dim unionRng As Range
Set unionRng = Union(Area1Rng, Area2Rng, Area3Rng, Area4Rng)

For Each itm In unionRng
  lstRangesUnion.AddItem itm.Address
Next

Open in new window


I predefined the ranges.

predefined ranges.
AL_XResearch

ASKER
So you're agreeing with me ?

To put another way; is there any way to create a range object where the areas within it themselves have areas ?
SOLUTION
Jeff Darling

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
AL_XResearch

ASKER
That doesn't really answer my question i am afraid.

What I am trying to determine is: Is it possible for the area object of a range to itself contain areas ?

I don't think so but I am looking for other's opinions.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
Rgonzo1971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
AL_XResearch

ASKER
Rgonzo1971: That was the conformation I was looking for.