+ Reply to Thread
Results 1 to 4 of 4

Print Setup VBA code behind a command button

  1. #1
    Forum Contributor
    Join Date
    04-20-2011
    Location
    New York, New York
    MS-Off Ver
    Excel 2010
    Posts
    160

    Print Setup VBA code behind a command button

    Hi,

    I have put together the following Print Setup VBA code behind a command button, but I can't get it to work properly:

    Sub Print_Report()
    Application.ScreenUpdating = False
    With Worksheets("Rates").PageSetup
    .DisplayPageBreaks = False
    .PrintTitleRows = "A9:LastColumn"
    .LeftMargin = Application.InchesToPoints(0.3)
    .RightMargin = Application.InchesToPoints(0.3)
    .TopMargin = Application.InchesToPoints(0.75)
    .BottomMargin = Application.InchesToPoints(0.75)
    .HeaderMargin = Application.InchesToPoints(0.3)
    .FooterMargin = Application.InchesToPoints(0.3)
    .CenterHorizontally = True
    .Orientation = xlPortrait
    .FirstPageNumber = xlAutomatic
    .FitToPagesWide = 1
    .FitToPagesTall = 1
    End With
    Application.ScreenUpdating = True
    Selection.PrintOut Copies:=1, Collate:=True
    End Sub

    I need to fix some of the code to incorporate the following rules:

    I want the Macro to:
    1: Include data in report from cells A5 to last column/last row
    2. Print column titles on every page (Columns titles are now found on Row 9 starting from A9 to last column)
    3. Autofit Columns to best Width
    4. Scale Worksheet to fit all columns on One Page

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Print Setup VBA code behind a command button

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Contributor
    Join Date
    04-20-2011
    Location
    New York, New York
    MS-Off Ver
    Excel 2010
    Posts
    160

    Re: Print Setup VBA code behind a command button

    Thanks Mordred,

    I will comply to the forum rules. I apologize for the inconvenience.

  4. #4
    Forum Contributor
    Join Date
    04-20-2011
    Location
    New York, New York
    MS-Off Ver
    Excel 2010
    Posts
    160

    Solved

    thanks everyone.

    BC

+ 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