Macro to hide/show rows and columns

L

Leo

I have a Excel worksheet using cells A1 to H430. There are quite a few empty
lines in this area, and when I print it out I don't want the empty lines. I
want to write a macro that will check column A (row headings), if one cell
has no content then the macro will hide the whole row.

Can someone please show me how this can be done in VBA code? Thanks a lot.
 
B

Bob Phillips

Not exactly sure what you want to hide, but this may help

Dim oRow As Range
For Each oRow In Range("A1:H43").Rows
If Cells(oRow.Row, "F").Value = "" Then
oRow.EntireRow.Hidden = True
End If
Next oRow

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)
 
L

Leo

Thanks a lot Bob. This probably is the coding I am looking for. The rows I
want to hide are those who have no content in column A. i.e., if A10 has no
content, hide the entire 10th row.

I will try your code to see if it works. Thanks again.
 
Top