Print Buttons

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

is it possible to use check boxes to choose certain sheets to print using a print button macro instead of creating a print button macro for every sheet.
 
Hi Toe

You can use a userform with a listbox and a button on it
Add this code in the Userform module
In the properties of the listbox set Multiselect to 1

Private Sub CommandButton1_Click()
Dim arr() As String
Dim N As Integer
N = 0
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
N = N + 1
ReDim Preserve arr(1 To N)
arr(N) = ListBox1.List(i)
End If
Next i
If N = 0 Then
MsgBox "You must select at least one Sheet"
Exit Sub
End If
ThisWorkbook.Worksheets(arr).Select
End Sub

Private Sub UserForm_Initialize()
For Each ws In ActiveWorkbook.Sheets
If ws.Visible = True Then
Me.ListBox1.AddItem (ws.Name)
End If
Next
End Sub



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)




Toe2222 said:
is it possible to use check boxes to choose certain sheets to print using a print button macro instead of creating a print
button macro for every sheet.
 
Oops

for testing I change this line

ThisWorkbook.Worksheets(arr).Select

It must be

ThisWorkbook.Worksheets(arr).PrintOut
 
Back
Top