ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hide rows in visual columns without data (https://www.excelbanter.com/excel-programming/393055-hide-rows-visual-columns-without-data.html)

johan

Hide rows in visual columns without data
 
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


p45cal[_50_]

Hide rows in visual columns without data
 
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

--
p45cal


"johan" wrote:

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



p45cal[_50_]

Hide rows in visual columns without data
 
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

--
p45cal


"p45cal" wrote:

Try a variation 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

--
p45cal


"johan" wrote:

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



johan

Hide rows in visual columns without data
 
Works fine. Thanks.



All times are GMT +1. The time now is 05:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com