Print worksheet if...

E

Esben

Does anyone know if there is a way in Excel that lets me print only those
worksheets containing specific values in particular cells?

Example:
In the worksheet named "Totals" (which collects data from a number of
other worksheets in the same workbook), the cell "Number of assignments" can
have the value "1" or "0", and the cell "Project" can have the value "F1" or
"0".

From the worksheet "Totals" I would like to be able to suggest the user to
only print those worksheets containg information - i.e. those worksheets
having delivered input to the "Totals" worksheet.
Is that possible - and if so, how is it done? (I use Excel 2002, and I am
not an expert at all....).

Thanks in advance and
best regards

Esben
(Denmark)
 
D

Debra Dalgleish

You could use a macro to print the sheet if specific cells are not
empty. For example:

'======================
Sub PrintSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "Totals" Then
If ws.Range("B4") <> "" And ws.Range("G4") <> "" Then
ws.PrintPreview
End If
End If
Next ws
End Sub
'==============================

To add the code to your workbook,--
Press Alt+F11, to open the Visual Basic Editor
Choose Insert>Module
Paste in the code
Close the VBE
 
Top