+ Reply to Thread
Results 1 to 3 of 3

Macro to print a variable selection

  1. #1
    Registered User
    Join Date
    07-05-2012
    Location
    Montreal, Quebec
    MS-Off Ver
    Excel 2003
    Posts
    5

    Macro to print a variable selection

    Hi everyone!
    So I have a problem that I just do not understand with one of my Macros...
    I have a form to select different parts of my file to print. The thing is, over time, the numbers of rows (corresponding to added people to a list) is subject to change... My "master list" is on one sheets and I want my Macro to see, on that sheet, what's the last row in a column with a value in it, and use that row number in other sheets to decide how many rows to print. What I did (And I know the code is not optimised... but I'm a novice and as long as it works... Plus I have that code All. Over. The. Place (I tested it and it worked, so I didn't see any problem in duplicating it)... and dread a little having to COMPLETELY change it all) was that:

    Please Login or Register  to view this content.
    Now the thing is... it comes back with Error 1004... BUT sometimes, it actually does work... for example, when I just added data in the range between A1 and End(xlDown) in Sheets(2)... so i just do not know what the problem is...
    So, I'll put a simplified workbook in attachement, and I'll summarize what I want my Macro to do:

    1-I want it to see how many rows in column A have data on the Worksheet called "CR" (to make sure it doesn't stop at A4 or A5, I have put a white "X" in both)
    2-Report that row number so it prints the selection from D1 to L"row number" on the worksheet "Février"

    On a second macro:
    1- Same thing
    2- Same thing but for selection from N1 to V"row number" on the worksheet "Février"

    etc.

    In the actual workbook, there's a lot more sheets, and a lot more macros (that are, fortunately, all working properly) but I deleted them all to ligthen the file size and for it all to be clearer... (the first Sheet "Formulaire" is were the form to select which part of the document will be printed is located... the Macro called "Imprimer" is the one that decides, according to the values entered, which printing macro to call).

    I'm sorry if it all seems a bit... foggy.

    Hope you can help... because I "read" my macro... and to my untrained eyes, it all seems coherent...

    Thank you for your help!
    Attached Files Attached Files
    Last edited by galegai; 01-28-2013 at 08:27 PM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro to print a variable selection

    Hi galegai

    You can't "Select" on a Sheet unless it's Active
    Please Login or Register  to view this content.
    Having said that...typically one does NOT need to use Select.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    07-05-2012
    Location
    Montreal, Quebec
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Macro to print a variable selection

    Thanks...
    Of course, that would be my downfall... Also, I am getting rid of the .select... I'll check how that goes

+ 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