A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
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)