ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Printing worksheets (https://www.excelbanter.com/excel-programming/403791-printing-worksheets.html)

Rick S.

Printing worksheets
 
This one I just can not figure out.
In my workbooks I will have many sheets, the first sheet and the last sheet
will always have the same name, "Master Sheet" and "Rev Record" respectivily.
I have a macro that prints the workbook but I do not want to print the first
and last worksheets. (The macro does much more than just print).
I use "ActiveWorkbook.PrintOut", which priints everything. My stumbling
block is, I do not know how many sheets will exist between the first and last
sheets nor do I know how to NOT print the two sheets mentioned.

If you understand this querry, raise your hand! ;)

Thanks in advance!

--
Regards

VBA.Noob.Confused
XP Pro
Office 2007


JLGWhiz

Printing worksheets
 
sub this for your current PrintOut.

x = ThisWorkbook.Sheets.Count
For i = 2 to x - 1
Sheets(i).PrintOut
Next

"Rick S." wrote:

This one I just can not figure out.
In my workbooks I will have many sheets, the first sheet and the last sheet
will always have the same name, "Master Sheet" and "Rev Record" respectivily.
I have a macro that prints the workbook but I do not want to print the first
and last worksheets. (The macro does much more than just print).
I use "ActiveWorkbook.PrintOut", which priints everything. My stumbling
block is, I do not know how many sheets will exist between the first and last
sheets nor do I know how to NOT print the two sheets mentioned.

If you understand this querry, raise your hand! ;)

Thanks in advance!

--
Regards

VBA.Noob.Confused
XP Pro
Office 2007


JLGWhiz

Printing worksheets
 
Of course, that code relies on "Master Sheet" always being the left most tab
and "Rev Record" always being the right most tab in the window view. It will
otherwise fail to do what you want.

"Rick S." wrote:

This one I just can not figure out.
In my workbooks I will have many sheets, the first sheet and the last sheet
will always have the same name, "Master Sheet" and "Rev Record" respectivily.
I have a macro that prints the workbook but I do not want to print the first
and last worksheets. (The macro does much more than just print).
I use "ActiveWorkbook.PrintOut", which priints everything. My stumbling
block is, I do not know how many sheets will exist between the first and last
sheets nor do I know how to NOT print the two sheets mentioned.

If you understand this querry, raise your hand! ;)

Thanks in advance!

--
Regards

VBA.Noob.Confused
XP Pro
Office 2007


JLGWhiz

Printing worksheets
 
You can also do it with an If ... Then statement:

For Each Sheet In ThisWorkbook
If Sheet.Name < "Master Sheet" And Sheet.Name < "Rev Record" Then
Sheet.PrintOut
End If
Next

"Rick S." wrote:

This one I just can not figure out.
In my workbooks I will have many sheets, the first sheet and the last sheet
will always have the same name, "Master Sheet" and "Rev Record" respectivily.
I have a macro that prints the workbook but I do not want to print the first
and last worksheets. (The macro does much more than just print).
I use "ActiveWorkbook.PrintOut", which priints everything. My stumbling
block is, I do not know how many sheets will exist between the first and last
sheets nor do I know how to NOT print the two sheets mentioned.

If you understand this querry, raise your hand! ;)

Thanks in advance!

--
Regards

VBA.Noob.Confused
XP Pro
Office 2007


Rick S.

Printing worksheets
 
This one will work! The sheets I stated will always be first and last.
Only had to make one minor change from your code:
x = ActiveWorkbook.Sheets.Count
Had to use ActiveWorkbook instead of ThisWorkbook, when using ThisWorkbook
it would only count two sheets?

Amazing, I simply did not think of iterating thru each sheet.

Thanks!!!

--
Regards

VBA.Noob.Confused
XP Pro
Office 2007



"JLGWhiz" wrote:

sub this for your current PrintOut.

x = ThisWorkbook.Sheets.Count
For i = 2 to x - 1
Sheets(i).PrintOut
Next

"Rick S." wrote:

This one I just can not figure out.
In my workbooks I will have many sheets, the first sheet and the last sheet
will always have the same name, "Master Sheet" and "Rev Record" respectivily.
I have a macro that prints the workbook but I do not want to print the first
and last worksheets. (The macro does much more than just print).
I use "ActiveWorkbook.PrintOut", which priints everything. My stumbling
block is, I do not know how many sheets will exist between the first and last
sheets nor do I know how to NOT print the two sheets mentioned.

If you understand this querry, raise your hand! ;)

Thanks in advance!

--
Regards

VBA.Noob.Confused
XP Pro
Office 2007



All times are GMT +1. The time now is 02:48 AM.

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