Can anybody give me the VBA code for a command button that will prin
the active worksheet and also give the user the option to select ho
many
Duke Carey - 23 Mar 2006 14:01 GMT
very simplistic
Dim i As Integer
i = InputBox("How many copies")
ActiveSheet.PrintOut copies:=i
> Can anybody give me the VBA code for a command button that will print
> the active worksheet and also give the user the option to select how
> many.
raymond.allan@bench.com - 23 Mar 2006 14:18 GMT
Create the button and associate it with this code
Sub Print_Sheet()
Dim Message, Title, Default, MyValue
Message = "Enter Number Of Copies To Print" ' Set prompt.
Title = "Print" ' Set title.
Default = "1" ' Set default.
MyValue = InputBox(Message, Title, Default)
If Not IsNumeric(MyValue) Then
MsgBox "Please enter a vilid number", vbInformation
GoTo NoPrinting
End If
ActiveWindow.SelectedSheets.PrintOut Copies:=MyValue
NoPrinting:
End Sub