+ Reply to Thread
Results 1 to 3 of 3

VBA - Help with Union All

  1. #1
    Forum Contributor
    Join Date
    12-26-2010
    Location
    Kansas City, Kansas
    MS-Off Ver
    Excel 2007
    Posts
    147

    VBA - Help with Union All

    Hi

    I have to track selective blocks of cells in a matrix that is 22 rows deep and
    180 columns wide. WHICH blocks I need to track are determined by a drop-down.

    Below is a snippet of code I tried using to accomplish this ......

    Please Login or Register  to view this content.

    Pass 1:
    =========
    ?oRngUnion.Address
    $C$2:$F$2,$U$2:$X$2,$AM$2:$AP$2,$BE$2:$BH$2,$BW$2:$BZ$2,$CO$2:$CR$2,$DG$2:$DJ$2,$DY$2:$EB$2,$EQ$2:$ET$2,$FI$2:$FL$2

    ?oRngUnionAll.Address
    $C$2:$F$2,$U$2:$X$2,$AM$2:$AP$2,$BE$2:$BH$2,$BW$2:$BZ$2,$CO$2:$CR$2,$DG$2:$DJ$2,$DY$2:$EB$2,$EQ$2:$ET$2,$FI$2:$FL$2


    Pass 2:
    =========
    ?oRngUnion.Address
    $C$3:$F$3,$U$3:$X$3,$AM$3:$AP$3,$BE$3:$BH$3,$BW$3:$BZ$3,$CO$3:$CR$3,$DG$3:$DJ$3,$DY$3:$EB$3,$EQ$3:$ET$3,$FI$3:$FL$3

    ?oRngUnionAll.Address
    $C$2:$F$3,$U$2:$X$3,$AM$2:$AP$3,$BE$2:$BH$3,$BW$2:$BZ$3,$CO$2:$CR$3,$DG$2:$DJ$3,$DY$2:$EB$3,$EQ$2:$ET$3,$FI$2:$FL$3

    In the 2nd pass the ORIGINAL ranges.addresses on oRngUnionAll are there
    but the NEW range address related to oRngUnion have not been included.

    I assume that Excel CAN DO this but that my approach is incorrect.

    Any help is appreciated.

    regards
    John
    Last edited by JohnM3; 09-01-2011 at 02:10 AM. Reason: Solved

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA - Help with Union All

    Hello John,

    I don't see a problem with the second pass. For example, your original range $C$2:$F$2 when unioned with $C$3:$F$3 will yield a new range of $C$2:$F$3. Did you expect something different?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    12-26-2010
    Location
    Kansas City, Kansas
    MS-Off Ver
    Excel 2007
    Posts
    147

    Thumbs up Re: VBA - Help with Union All

    Hi Leith

    Thank you for responding.

    After the 2nd pass I expected the range oRngUnionAll to hold all of the following:

    $C$2:$F$2,$U$2:$X$2,$AM$2:$AP$2,$BE$2:$BH$2,$BW$2:$BZ$2,$CO$2:$CR$2,$DG$2:$DJ$2,$DY$2:$EB$2,$EQ$2:$E T$2,$FI$2:$FL$2;$C$3:$F$3,$U$3:$X$3,$AM$3:$AP$3,$BE$3:$BH$3,$BW$3:$BZ$3,$CO$3:$CR$3,$DG$3:$DJ$3,$DY$3:$EB$3,$EQ$3:$E T$3,$FI$3:$FL$3

    In reading your reply I think I've done a _DUH_ and missed the point that Excel has - in effect -
    consolidated the ranges after the second pass. I believe this is what you are saying (?).
    .
    If correct then (a) Excel (range union) was always working correctly and (b) it is of no help
    with respect to isolating each - what I will call range blocks - e.g. $C$2:$F$2 , $C$3:$F$3 in that
    I need these isolated range blocks to build series data for a chart.
    .
    I have already built code to do the isolation but it is ugly and inefficient code.
    .
    Warning:This code will hurt your ears -g- and truncated so that I can post it
    .
    Please Login or Register  to view this content.
    I am just not thinking clearly about this.

    But thank you very much for pointing out that the Range Union was - if fact - working
    correctly and efficiently.

    regards
    John

+ 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