I Tried to write a function which returns a compilation of ranges by using Union in a loop. Then function in principle looks like this:
Public Function rRange() As Range
Dim rSubRange As Range
Set rRange = .... any range
For i = 1 To 5
Set rSubRange = .... any range build with i
Set rRange = Application.Union(rRange, rSubRange)
rRange.Select ' This is just to monitor how the range "grows"
Next i ' I do stop the execution here to check the selection
The problem is that rRange allways just comprises of the very last rSubRange. I.e. the Union does not grow as expected.
![]()
Bookmarks