R
rob nobel
1. The following code opens a user form which gives the user a choice to
select 1 or more items (which are sheets). He then enters how many to print.
What I can't work out is how to make the procedure print EACH of the
selections and for the number of copies desired. (selecting the number of
copies will apply to each item selected.)
2. The ' choose an item part doesn't do its thing either as it still prints
if nothing is selected. Works OK if set to single selection, just can't
work it for multiple.
3. ALSO, if its not too difficult, can the AddItem section cause the
userform to show the names of the sheets in the list, bearing in mind that
the names of the sheet may change but not the numbers of the sheet. (sheets
1,2,3,8)
Option Explicit
'Allow only whole numbers
Private Sub TextBox1_KeyPress(ByVal _
KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 48 To 57
Case Else
KeyAscii = 0
End Select
End Sub
'Part of Allow only whole numbers procedure to stop Ctrl button press
Private Sub TextBox1_KeyDown(ByVal _
KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If Shift = 2 Then KeyCode = 0
End Sub
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub OKButton_Click()
Dim vNoCopies As String
' choose an item
If ListBox1.ListIndex = -1 Then
MsgBox "Select from the list.", vbInformation
Exit Sub
End If
vNoCopies = TextBox1.Text
If vNoCopies = "" Then
MsgBox "You must enter a number."
Unload Me
ufPrintNo.Show
Exit Sub
End If
Select Case ListBox1.ListIndex
Case 0
Sheet1.PrintOut From:=1, To:=1, Copies:=vNoCopies
Case 1
Sheet2.PrintOut From:=1, To:=1, Copies:=vNoCopies
Case 1
Sheet3.PrintOut From:=1, To:=1, Copies:=vNoCopies
Case 1
Sheet8.PrintOut From:=1, To:=1, Copies:=vNoCopies
End Select
Unload Me
End Sub
Private Sub UserForm_Initialize()
With ufPrintNo.ListBox1
.RowSource = ""
.AddItem "Bank Reconcilliation"
.AddItem "Financial Statement"
.AddItem "Balance Sheet"
.AddItem "Statistics Sheet"
End With
End Sub
select 1 or more items (which are sheets). He then enters how many to print.
What I can't work out is how to make the procedure print EACH of the
selections and for the number of copies desired. (selecting the number of
copies will apply to each item selected.)
2. The ' choose an item part doesn't do its thing either as it still prints
if nothing is selected. Works OK if set to single selection, just can't
work it for multiple.
3. ALSO, if its not too difficult, can the AddItem section cause the
userform to show the names of the sheets in the list, bearing in mind that
the names of the sheet may change but not the numbers of the sheet. (sheets
1,2,3,8)
Option Explicit
'Allow only whole numbers
Private Sub TextBox1_KeyPress(ByVal _
KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 48 To 57
Case Else
KeyAscii = 0
End Select
End Sub
'Part of Allow only whole numbers procedure to stop Ctrl button press
Private Sub TextBox1_KeyDown(ByVal _
KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If Shift = 2 Then KeyCode = 0
End Sub
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub OKButton_Click()
Dim vNoCopies As String
' choose an item
If ListBox1.ListIndex = -1 Then
MsgBox "Select from the list.", vbInformation
Exit Sub
End If
vNoCopies = TextBox1.Text
If vNoCopies = "" Then
MsgBox "You must enter a number."
Unload Me
ufPrintNo.Show
Exit Sub
End If
Select Case ListBox1.ListIndex
Case 0
Sheet1.PrintOut From:=1, To:=1, Copies:=vNoCopies
Case 1
Sheet2.PrintOut From:=1, To:=1, Copies:=vNoCopies
Case 1
Sheet3.PrintOut From:=1, To:=1, Copies:=vNoCopies
Case 1
Sheet8.PrintOut From:=1, To:=1, Copies:=vNoCopies
End Select
Unload Me
End Sub
Private Sub UserForm_Initialize()
With ufPrintNo.ListBox1
.RowSource = ""
.AddItem "Bank Reconcilliation"
.AddItem "Financial Statement"
.AddItem "Balance Sheet"
.AddItem "Statistics Sheet"
End With
End Sub