+ Reply to Thread
Results 1 to 2 of 2

Compiling a Union

  1. #1
    Registered User
    Join Date
    08-22-2011
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    51

    Compiling a Union

    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.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Compiling a Union

    Welcome to the forum.

    This works fine for me:

    Please Login or Register  to view this content.
    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1