Consulting

Results 1 to 3 of 3

Thread: printing issue

  1. #1

    printing issue

    How can i make the code print out 2 sheets everytime, and then the one of 4 sheets that has a number in F4?

    [VBA]
    Sub Macro1()
    '
    ' Macro1 Macro
    ' Macro recorded 13/02/2007 by Rodders
    '
    With ActiveWorkbook
    For Each Worksheet In .Worksheets
    If "F2" > 0 Then

    Worksheet.Activate
    Worksheet.Visible = xlSheetVisible
    With ActiveSheet.PageSetup
    .PaperSize = xlPaperA4
    .Zoom = False
    .FitToPagesWide = 1
    .FitToPagesTall = 1
    .LeftFooter = ""

    End With
    Next Worksheet
    End With
    '
    ActiveWorkbook.PrintOut Copies:=1, Collate:=True
    '
    End Sub
    [/VBA]

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Try this Rodney:
    [VBA]Sub Macro1()
    Dim WS As Worksheet
    For Each WS In ActiveWorkbook.Worksheets
    If Not WS.Range("F2") = 0 Then
    ' WS.PrintPreview 'for testing only
    WS.PrintOut Copies:=2, Collate:=True
    End If
    Next WS
    End Sub[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Rodney
    When you post code, please select it and click the VBA button to format it as shown.
    This will also highlight coding errors where the indenting is not balanced, showing that you are missing an End If statement in Post #1
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •