ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selective Printing of Excel Worksheets using Macro (https://www.excelbanter.com/excel-programming/389919-selective-printing-excel-worksheets-using-macro.html)

Daniel Clough

Selective Printing of Excel Worksheets using Macro
 
I need a VBS script for an Excel Macro to print a worksheet but only if one
of the fields on the sheet has been filled. At the moment my Macro prints
every worksheet that might be needed and I'm wasting a ton of paper and ink
every time.

Any help :)

Dan

Mike H

Selective Printing of Excel Worksheets using Macro
 
Try this:-

Sub selectiveprint()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
wSheet.Select
If Cells(1, 1).Value = "Print Me" Then
wSheet.PrintOut
End If
Next wSheet
End Sub

Mike

"Daniel Clough" wrote:

I need a VBS script for an Excel Macro to print a worksheet but only if one
of the fields on the sheet has been filled. At the moment my Macro prints
every worksheet that might be needed and I'm wasting a ton of paper and ink
every time.

Any help :)

Dan



All times are GMT +1. The time now is 05:27 PM.

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