Coopercell
New Member
- Joined
- Apr 3, 2016
- Messages
- 7
Hi
I am trying to make a generic print code that depending on what sheet it is activated from it will print the matching sheet for that page. I currently have the following code but am unsure of how to get it to reference the cell and retrive the codename of the sheet in which it has to print. I was looking to put the codename of the sheet I need printed in cell X1 of the starting sheet.
Sub PrintSpecificSheet1()
Dim wks As Worksheet
Set wks = ActiveWorkbook.Sheets(Sheet11.Name)
If wks.Visible <> xlSheetVisible Then
Application.ScreenUpdating = False
wks.Visible = xlSheetVisible
wks.Calculate
wks.Activate
wks.PrintOut Copies:=Sheets(Sheet4.Name).Range("X5").Value, IgnorePrintAreas:=False
wks.Visible = xlSheetHidden
Application.Goto Reference:=Worksheets(Sheet4.Name).Range("A1"), _
scroll:=True
Application.ScreenUpdating = True
Else
wks.PrintOut Copies:=Sheets(Sheet4).Range("X5").Value, IgnorePrintAreas:=False
Application.Goto Reference:=Worksheets(Sheet4).Range("A1"), _
scroll:=True
End If
Set wks = Nothing
End Sub
Thanks in advance
I am trying to make a generic print code that depending on what sheet it is activated from it will print the matching sheet for that page. I currently have the following code but am unsure of how to get it to reference the cell and retrive the codename of the sheet in which it has to print. I was looking to put the codename of the sheet I need printed in cell X1 of the starting sheet.
Sub PrintSpecificSheet1()
Dim wks As Worksheet
Set wks = ActiveWorkbook.Sheets(Sheet11.Name)
If wks.Visible <> xlSheetVisible Then
Application.ScreenUpdating = False
wks.Visible = xlSheetVisible
wks.Calculate
wks.Activate
wks.PrintOut Copies:=Sheets(Sheet4.Name).Range("X5").Value, IgnorePrintAreas:=False
wks.Visible = xlSheetHidden
Application.Goto Reference:=Worksheets(Sheet4.Name).Range("A1"), _
scroll:=True
Application.ScreenUpdating = True
Else
wks.PrintOut Copies:=Sheets(Sheet4).Range("X5").Value, IgnorePrintAreas:=False
Application.Goto Reference:=Worksheets(Sheet4).Range("A1"), _
scroll:=True
End If
Set wks = Nothing
End Sub
Thanks in advance