Macro to hide/show rows and columns

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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)
 
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.
 

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

Back
Top