Hello,
I have a worksheet that's split into groups of data with a heading at the top of each. For instance, row 3 has a heading, then 4-9 have data that goes with it, then row 10 has another heading, and so on. Some of the rows of data are hidden using VBA based on certain values, leaving the occasional header with no data under it.
I'd like to hide the data-less headers, but because there are hidden rows in between, I'm struggling to catch the right rows. Basically, every header row is blank in col M and very row with data is not. Here's the code I've been playing with, but it doesn't continue until it's found the next visible row. Any thoughts on how to make it work?
I have a worksheet that's split into groups of data with a heading at the top of each. For instance, row 3 has a heading, then 4-9 have data that goes with it, then row 10 has another heading, and so on. Some of the rows of data are hidden using VBA based on certain values, leaving the occasional header with no data under it.
I'd like to hide the data-less headers, but because there are hidden rows in between, I'm struggling to catch the right rows. Basically, every header row is blank in col M and very row with data is not. Here's the code I've been playing with, but it doesn't continue until it's found the next visible row. Any thoughts on how to make it work?
Code:
Dim N as long
Dim I as long
Dim x as long
N = Sheets("FoE").Range(Cells(Rows.Count, "B")).End(xlUp)
For i = 4 To N
x = 1
If Cells(i, 13).Value = "" Then
If Cells(i, 13).Offset(x, 0).Hidden = True Then
x = x + 1
ElseIf Cells(i, 13).Offset(x, 0).Value = "" Then
Range(i, 13).EntireRow.Hidden = True
End If
End If
Next i