ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Print code????? (https://www.excelbanter.com/excel-programming/356890-vba-print-code.html)

Chris Watson[_7_]

VBA Print code?????
 

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

--
Chris Watso
-----------------------------------------------------------------------
Chris Watson's Profile: http://www.excelforum.com/member.php...nfo&userid=470
View this thread: http://www.excelforum.com/showthread.php?threadid=52564


Duke Carey

VBA Print code?????
 
very simplistic

Dim i As Integer

i = InputBox("How many copies")
ActiveSheet.PrintOut copies:=i


"Chris Watson" wrote:


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.


--
Chris Watson
------------------------------------------------------------------------
Chris Watson's Profile: http://www.excelforum.com/member.php...fo&userid=4700
View this thread: http://www.excelforum.com/showthread...hreadid=525646



[email protected]

VBA Print code?????
 

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



All times are GMT +1. The time now is 12:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com