+ Reply to Thread
Results 1 to 5 of 5

Print Macro for specific Ranges in a worksheet

  1. #1
    Registered User
    Join Date
    10-22-2012
    Location
    Texas, US
    MS-Off Ver
    Excel 2007
    Posts
    10

    Print Macro for specific Ranges in a worksheet

    I have a worksheet with column headings and data that I want to add a print button for users to be able to print their report displayed on the screen to the printer that is set as their default. This worksheet expands all the way to column CD but I just want the print to focus on a specific range Columns A : S. Some reports will be long some will be short but I want the pages printed to depend on the length of the report. The last row of data in column H can be used to determine the length of the report. What vba code can I use for this task so I can assign a Print command button to it. Thanks in advance. The report should have the following specifications.
    Landscape
    Print 1 Page Wide
    Header=0.3
    Footer=0.3
    Top=0.6
    Bottom=0.6
    Left=0.6
    Right=0.6
    Gridlines should be checked

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Print Macro for specific Ranges in a worksheet

    You can use your macro recorder to set up the printer specs.
    this code will set your print area
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-22-2012
    Location
    Texas, US
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Print Macro for specific Ranges in a worksheet

    Hi Dave my print code is just printing the 1st page even when some reports are more than 1 page. I incorporated your code with my macro but Im sure I am missing something or coded wrong. Can you please look at my code and tell me what Im doing wrong to fix that problem. Thanks for your help
    Please Login or Register  to view this content.
    Last edited by davesexcel; 11-16-2012 at 08:38 AM.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Print Macro for specific Ranges in a worksheet

    Maybe this
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-22-2012
    Location
    Texas, US
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Print Macro for specific Ranges in a worksheet

    Hi Dave I fixed the problem. I had toincrease my number of pages in this code
    ExecuteExcel4Macro "PRINT(2,1,1,1,,,,,,,,2,,,TRUE,,FALSE)

    to

    ExecuteExcel4Macro "PRINT(2,1,30,1,,,,,,,,2,,,TRUE,,FALSE)

+ 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