ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Printing a selected worksheet (https://www.excelbanter.com/excel-programming/438559-printing-selected-worksheet.html)

caldog

Printing a selected worksheet
 
I have multiple worksheets to select from, but the user will only need to
print one of those sheets. How can I in code through an input box function
ask the user to input the sheet name that is needed to be printed?

I have just checked for the last hour hunting for an answer, so sorry if
this question has been asked before.


JLGWhiz[_2_]

Printing a selected worksheet
 
prtFile = InputBox("Enter a file name (with/without extension?)", "FILE
NAME")
Workbooks(prtFile).PrintOut





"caldog" wrote in message
...
I have multiple worksheets to select from, but the user will only need to
print one of those sheets. How can I in code through an input box
function
ask the user to input the sheet name that is needed to be printed?

I have just checked for the last hour hunting for an answer, so sorry if
this question has been asked before.




Jacob Skaria

Printing a selected worksheet
 
Try

Sub Macro()
Dim strSheet As String
strSheet = InputBox("Enter sheet name to be printed")
ActiveWorkbook.Sheets(strSheet).PrintOut Copies:=1, Collate:=True
End Sub


Would suggest to have a userform with a combo box listing the sheet names...

--
Jacob


"caldog" wrote:

I have multiple worksheets to select from, but the user will only need to
print one of those sheets. How can I in code through an input box function
ask the user to input the sheet name that is needed to be printed?

I have just checked for the last hour hunting for an answer, so sorry if
this question has been asked before.


caldog

Printing a selected worksheet
 
Thanks folks that worked just great

"Jacob Skaria" wrote:

Try

Sub Macro()
Dim strSheet As String
strSheet = InputBox("Enter sheet name to be printed")
ActiveWorkbook.Sheets(strSheet).PrintOut Copies:=1, Collate:=True
End Sub


Would suggest to have a userform with a combo box listing the sheet names...

--
Jacob


"caldog" wrote:

I have multiple worksheets to select from, but the user will only need to
print one of those sheets. How can I in code through an input box function
ask the user to input the sheet name that is needed to be printed?

I have just checked for the last hour hunting for an answer, so sorry if
this question has been asked before.



All times are GMT +1. The time now is 07:09 AM.

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