Printing empty rows

M

Manuel Murieta

I have a worksheet of 30 rows and 2 columns
There are intermittent rows that have no data
How can I print the worksheet and not have the spaces due to the empty rows.

For example Here is a portion of the follwoing worksheet:

.. A B
1 yellow apples
2 green pears
3 oranges
4 blue skies
5
6 violet sunsets
7 black

I would like it to print as follows:
yellow apples
green pears
oranges
blue skies
violet sunsets
black

Not as follows:
yellow apples
green pears
oranges
blue skies

violet sunsets
black
 
R

Ron de Bruin

You can use a macro to print

Try

This example will loop through row 1:30 in "Sheet1"
If every cell in column A:G is empty it will hide that row.
After the loop it print the sheet and then unhide the rows.

You can also use this with non contiguous ranges Range("B1,D1:G1")
If the cells in column B and D:G are empty it will hide that row.


Sub Hide_Print_Unhide()
Dim rw As Long
Application.ScreenUpdating = False

With Sheets("Sheet1")
For rw = 1 To 30
If Application.WorksheetFunction.CountA( _
.Cells(rw, 1).Range("A1:G1")) = 0 Then _
.Rows(rw).Hidden = True
Next rw
.PrintOut ' for testing use .PrintPreview
.Range("A1:A30").EntireRow.Hidden = False
End With

Application.ScreenUpdating = True
End Sub
 

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