hiding rows

K

Khalil Handal

Hi,
I want to use the conditional formating of a certain range of cells so that:
if a cell in that range is empty (nothing is shown) hide the entire row.
note: the values in the cells are copied from other cells in a different
worksheet.
If this is not possible with conditional formating can it be done with VBA
and How?
 
R

Ron de Bruin

Not possible with CF

Look here for a few ways
http://www.rondebruin.nl/print.htm#Hide

For example

Hide Empty rows, Print and unhide the rows

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