Hide rows in visual columns without data

J

johan

Hello,

Somebody can help me with below question ?.

I have a sheet with always visible the columns A and B.
From the other columns (C till the last used column) some columns
(each time different ones) are hidden. In the visible columns some of
the records shows registrated data.

I need some help for a macro that hide all the rows of the "at that
moment visible columns" that contains no registrated data in all the
visible columns in the same row.

For example,...

visible columns: D E H
row 3: x x
row 4:
row 5: x x
row 6: x
row 7:
row 8: x

The macro should hide the rows 4 and 7 because the visible columns at
that moment shows no registrated data in each record of that specific
row (in the shown columns from C till the last used).

Regards and waiting for the solution,
thanks.

Johan
 
G

Guest

Try a varioation of:

Set TheRange = ActiveSheet.Range("C3:p15")
For Each rw In TheRange.Rows
AllBlank = True
For Each cll In rw.SpecialCells(xlCellTypeVisible).Cells
cll.Select
If cll.Value <> "" Then AllBlank = False: Exit For
Next cll
If AllBlank Then rw.Hidden = True
Next rw
End Sub
 
G

Guest

Sorry, I left the top two lines out, here it is in full:

Sub blah()
Dim TheRange As Range
Set TheRange = ActiveSheet.Range("C3:p15")
For Each rw In TheRange.Rows
AllBlank = True
For Each cll In rw.SpecialCells(xlCellTypeVisible).Cells
cll.Select
If cll.Value <> "" Then AllBlank = False: Exit For
Next cll
If AllBlank Then rw.Hidden = True
Next rw
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