ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Hide/Unhide row VBA (https://www.excelbanter.com/excel-discussion-misc-queries/225197-hide-unhide-row-vba.html)

Scafidel[_2_]

Hide/Unhide row VBA
 
A form sheet fills a "document" sheet with headings and information with a
blank row between each part. But when a heading repeats (by cell formula),
it appears as empty, so I am using this VBA formula to hide the empty row.
But I have many rows just like it and I would like a single formula that
would check the whole sheet. Luckily, it is every sixth row, i.e.,
A24,A30,A36,A42, etc.

Private Sub Worksheet_Change(ByVal Target As Range)
If Me.Range("A30") = "" Then
Rows("30").Hidden = True
ElseIf Me.Range("A30") "" Then
Rows("30").Hidden = False
End If

How would I have one formula check every sixth row down to say, A200?
Thanks
--
Scafidel
Lafayette, Louisiana

Jarek Kujawa[_3_]

Hide/Unhide row VBA
 
Private Sub Worksheet_Change(ByVal Target As Range)

For Each cell In Range("H30:H200").Cells
If IsEmpty(cell) And Int(cell.Row / 6) = cell.Row / 6 Then
cell.Rows.EntireRow.Hidden = True
Else
cell.Rows.EntireRow.Hidden = False
End If
Next cell

End Sub


Użytkownik "Scafidel" napisał w wiadomości
...
A form sheet fills a "document" sheet with headings and information with a
blank row between each part. But when a heading repeats (by cell
formula),
it appears as empty, so I am using this VBA formula to hide the empty row.
But I have many rows just like it and I would like a single formula that
would check the whole sheet. Luckily, it is every sixth row, i.e.,
A24,A30,A36,A42, etc.

Private Sub Worksheet_Change(ByVal Target As Range)
If Me.Range("A30") = "" Then
Rows("30").Hidden = True
ElseIf Me.Range("A30") "" Then
Rows("30").Hidden = False
End If

How would I have one formula check every sixth row down to say, A200?
Thanks
--
Scafidel
Lafayette, Louisiana





All times are GMT +1. The time now is 06:35 PM.

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