ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet printing (https://www.excelbanter.com/excel-programming/395334-worksheet-printing.html)

Colin Telfer

Worksheet printing
 
Does anyone have any routines available which will allow one to print off
worksheets in a spreadsheet which have entries in them, e.g. worksheets 1,
4, and 5 will have data in whereas 2 and 3 are empty?

Thanks in advance

Colin



Otto Moehrbach

Worksheet printing
 
Colin
The code would have to have a means of determining that a sheet is empty
or not empty. This can be done by various means, some easier than others.
Is there some clue (this cell has an entry or that range has some entries,
etc.) that the code can use to make this determination? The code can even
be written to make this determination without any clues at all, if
necessary.
Basically, the code would be a For loop through all the sheets in the
workbook, then determine which ones to print by the clues you furnish, print
it (or not) and then go to the next sheet. Post back with a bit more detail
about what you have. HTH Otto
"Colin Telfer" wrote in message
...
Does anyone have any routines available which will allow one to print off
worksheets in a spreadsheet which have entries in them, e.g. worksheets 1,
4, and 5 will have data in whereas 2 and 3 are empty?

Thanks in advance

Colin





OssieMac

Worksheet printing
 
Hi Colin,

The following code should perform the test you want.

Sub Test_Used_Area()

Dim rng1 As Range
Dim ws As Worksheet

For Each ws In Sheets
ws.Select
Set rng1 = ws.UsedRange

If rng1.Cells.Count = 1 And rng1.Cells(1, 1) = Empty Then
MsgBox ws.Name & " is empty"
Else
MsgBox ws.Name & " is not empty"
End If

Next ws
End Sub

Regards,

OssieMac

"Colin Telfer" wrote:

Does anyone have any routines available which will allow one to print off
worksheets in a spreadsheet which have entries in them, e.g. worksheets 1,
4, and 5 will have data in whereas 2 and 3 are empty?

Thanks in advance

Colin





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

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