Code:
Private Sub CancelButton_Click()
Unload UserForm2
End Sub
Private Sub OKButton_Click()
Dim Cell As Range
If All Then
Sheets("Quality Graph").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("TCHr Graph").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("AHT Graph").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("PQ Graph").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Trends Graph").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If QualityGraph Then
Sheets("Quality Graph").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If TCHrGraph Then
Sheets("TCHr Graph").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If AHTGraph Then
Sheets("AHT Graph").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If PQGraph Then
Sheets("PQ Graph").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If PQTrendsGraph Then
Sheets("Trends Graph").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
Sheets("Generate").Select
Range("F2").Select
End Sub
This is what I have so, however I can't manage to add the numbers of copies in.. any ideas at all would be appreciated!
Suggestion 1:
Give the controls a prefix so it is obvious what they are. For example, your option buttons ought to have names like optAll and optQualityGraph. This makes it easier for someone else to understand the code, and for you to understand it next month when you want to fix it up.
Also, when using the value of the control, state it explicitly. I know Value is default for an option button, but this:
If optAll.Value Then
is more understandable than
if All then
Suggestion 2:
Don't select different objects and then work on the selected object. It's slower and causes lots of screen flicker. Change this:
Sheets("Quality Graph").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
to this:
Charts("Quality Graph").PrintOut Copies:=1, Collate:=True
3. What's the name of the dropdown with the quantity? Assuming it's cboPrintQuantity, then:
Charts("Quality Graph").PrintOut Copies:=cboPrintQuantity.Value, Collate:=True