I can't figure out how to find all the internal name ranges that are within a specified range.
For example, there are three ranges: R_1, R_2, and R_3.
I need to search through all the ranges (for each) to find only those that will fit inside the specified range.
In this example, the specified range is R_2. At the output, I need to find R_2 and R_3. But not R_1.
Dim nm As Name
For Each nm In ThisWorkbook.Names
*** CODE HERE ***
Next nm
I previously used the following code.
Dim nm As Name
Dim rng As Range
Set rng = Range("R_2") 'specified range
For Each nm In ThisWorkbook.Names
If Not Intersect(rng,Range(nm)) Is Nothing Then
*** CODE HERE ***
End If
Next nm
If I needed to locate all internal ranges but there were no external ranges, it worked. That is, I would have no trouble locating R 2 and R 3 if there was no range of R 1. So looking for intersections is inappropriate if there is an external range.
Please let me know what you can come up with in this situation. I should also mention that range names can vary, so I specifically require an enumeration of all ranges (for each).