+ Reply to Thread
Results 1 to 3 of 3

Help me to print a range before the other in a Union method.

  1. #1
    Registered User
    Join Date
    05-18-2012
    Location
    Puerto Rico
    MS-Off Ver
    Excel 2007
    Posts
    4

    Help me to print a range before the other in a Union method.

    Hello.

    I want to print the range "a", which is belongs of the union ranges A46:I90 and A1:I45 in the order as written the code. To print the range A46:I90 first,

    and then A1:I45.

    The order in which they are printing is quite the opposite, and because the computer prints of this union the range that has the lower row first.

    How you can fix it?


    Sub Print_Regis()

    Dim a As Range

    Set a = Union(Sheets("Sheet1").Range("A46:I90"), Sheets("Sheet2").Range("A1:I45"))
    a.PrintOut

    End Sub

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

    Re: Help me to print a range before the other in a Union method.

    By definition, a range is wholly contained on a single worksheet. Your code, which attempts to union ranges on two different sheets, will generate a runtime error.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,440

    Re: Help me to print a range before the other in a Union method.

    Welcome to the forum. For future reference, you should read the forum rules and add code tags to your code excerpt(s).

    That said, I'm guessing that there is an error in the example code as you can't have a union of ranges on two different sheets.

    Assuming that you are actually referring to the same sheet, the union of A46:I90 and A1:I45 is the range A1:I90, hence the reason the print comes out sequentially.

    The only way you will get the ranges printed out in the order you want them is to print the ranges separately but I would expect they would appear on separate sheets.

    Alternatively, you could copy the ranges to another (temporary) sheet and then print that sheet.

    For example:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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