Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Spreadsheets (https://www.askmehelpdesk.com/forumdisplay.php?f=395)
-   -   Macro to print a page-or not, based on a cells content. (https://www.askmehelpdesk.com/showthread.php?t=400340)

  • Sep 27, 2009, 11:26 AM
    rsdjimbie
    Macro to print a page-or not, based on a cells content.
    Code:

    Sub Printing()
    '
    ' Printing Macro
    ' Macro recorded 15/12/2005 by Lenah
    '
    ' Keyboard Shortcut: Ctrl+p
    '
        Application.ScreenUpdating = False
        Sheets("Invoice").Select
        ActiveWindow.SelectedSheets.PrintOut Copies:=4, Collate:=True
        Sheets("SAD500").Select
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
       
        'Print this sheet only if cell AX4=>2
        Sheets("SAD501-1").Select
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
       
        'Print this sheet only if cell AX4=3
        Sheets("SAD501-2").Select
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
       
       
        Sheets("Manhood").Select
        ActiveWindow.SelectedSheets.PrintOut Copies:=2, Collate:=True
        Sheets("Invoice").Select
        Application.ScreenUpdating = True
    End Sub


    Hope the code sample is sufficient.
    Thanks a mil.
  • Sep 27, 2009, 11:44 PM
    JBeaucaire

    Try this:
    Code:

    Sub Printing()
    '
    ' Printing Macro
    ' Macro recorded 15/12/2005 by Lenah
    ' Edited by JBeaucaire  (27/9/2009)
    ' Keyboard Shortcut: Ctrl+p
    '
    Application.ScreenUpdating = False
       
    Sheets("Invoice").Activate
    ActiveWindow.SelectedSheets.PrintOut Copies:=4, Collate:=True
       
    Sheets("SAD500").Activate
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
       
    'Print this sheet only if cell AX4=>2
    If Sheets("SAD501-1").Range("AX4") >= 2 Then
        Sheets("SAD501-1").Select
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    End If
       
    'Print this sheet only if cell AX4=3
    If Sheets("SAD501-2").Range("AX4") = 3 Then
        Sheets("SAD501-2").Activate
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    End If
       
    Sheets("Manhood").Activate
    ActiveWindow.SelectedSheets.PrintOut Copies:=2, Collate:=True
    Sheets("Invoice").Activate
    Application.ScreenUpdating = True
    End Sub

  • Oct 1, 2009, 11:24 AM
    rsdjimbie
    Works a treat, thank you very much.

  • All times are GMT -7. The time now is 10:46 AM.