Printing worksheets

R

Rick S.

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
 
J

JLGWhiz

sub this for your current PrintOut.

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

JLGWhiz

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.
 
J

JLGWhiz

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
 
R

Rick S.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top