Macro to hide rows containing no data

J

John

My spreadsheet is A1:Q308. I would like only the rows
which contain a value in the Q column that is less than
zero or greater than zero to be printed. There are also
some blank rows which contain no data or formulas in the
A1:Q308 worksheet. I would like the macro to search the
sheet, suppress the rows that do not qualify for display,
and let me print what remains.
 
D

Dave Peterson

I think I wouldn't use a macro.

I'd select the range and do Data|Filter|autofilter.

You can use the dropdown on each header cell and show or hide the values you
want.

There's even an option for Custom.

"Does not equal" 0
And
"does not equal" (leave blank)

may be useful.
 
N

N10

Paul Lautman said:
HAve you thought of just using Auto Filter?

tHIS SEEMS TO WORK

Sub ENTIREROWS()

Dim X As Range


Dim FLAG As Integer
Range("A1").Select
For Each Row In ActiveSheet.UsedRange
For Each CELL In Row
CELL.Select
If CELL.Value > "" Then FLAG = 1
Next
If FLAG < 1 Then ActiveCell.Select
If FLAG < 1 Then Selection.EntireRow.Delete
FLAG = 0
Next
End Sub

N10
 
Top