Share via

EXCEL CONDITIONAL PRINTING

Anonymous
2010-10-04T05:50:17+00:00

I have a workbook with six worksheets.  I have created buttons on worksheet #1 with macros to print specific worksheet that matches cell entry in C5. Users are making mistakes and selecting the wrong button. I would like to, instead, have only one print button that will print the worksheet that matches the entry in cell C5. 

I'm looking for a way to code the button so that one button can handle this process. 

Sheet 1 = master data entry worksheet

Sheet 2 = one

Sheet 3 = two

Sheet 4 = three

I'd like to have sheet 2 print when "one" is entered in cell C5 on sheet #1.  Or, print sheet 3 when "two" is entered in cell C5 on sheet #1, and so on.

Any help with vba coding or other tip to conditionally print would be appreciated.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2010-10-04T08:07:51+00:00

I have a workbook with six worksheets.  I have created buttons on worksheet #1 with macros to print specific worksheet that matches cell entry in C5. Users are making mistakes and selecting the wrong button. I would like to, instead, have only one print button that will print the worksheet that matches the entry in cell C5. 

I'm looking for a way to code the button so that one button can handle this process. 

Sheet 1 = master data entry worksheet

Sheet 2 = one

Sheet 3 = two

Sheet 4 = three

I'd like to have sheet 2 print when "one" is entered in cell C5 on sheet #1.  Or, print sheet 3 when "two" is entered in cell C5 on sheet #1, and so on.

Any help with vba coding or other tip to conditionally print would be appreciated.

Private Sub CommandButton1_Click()

    Select Case LCase(Me.Range("C5").Value)

        Case "one"

            Worksheets("Sheet2").PrintOut

        Case "two"

            Worksheets("Sheet3").PrintOut

        Case "three"

            Worksheets("Sheet4").PrintOut

        Case Else

            MsgBox "Please, insert right data"

    End Select

End Sub


Mauro Gamberini - Microsoft© MVP(Excel)

http://www.maurogsc.eu/

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2010-10-05T04:01:26+00:00

    Worked like magic.  Had to modify the first two lines to:

    Application.EnableEvents = False

    Select Case Worksheets ("sheet")Range("C5")

    Thanks.

    Was this answer helpful?

    0 comments No comments