I am looking for assistance in revising code for one of my worksheets (Sheet3). In essence, I want to look at a specific cell within a range and if that cell is blank, then hide the entire range. Sheet3 has 5 ranges to gauge whether to hide the blank rows and thought a Union would be the best option. The Sheet's ranges are as follows:
Range 1
Range 1
- A11:A60 - Hide rows that are blank in range (A11 will never be blank, but the rest of the range could be blank and would need hiding)
- A71:A120 - If cell A71 is blank, Hide A65:A122. Otherwise hide all rows that are blank in range A71:A120.
- A131:A180 - If cell A131 is blank, Hide A125:A182. Otherwise hide all rows that are blank in range A131:A180.
- A191:A240 - If cell A191 is blank, Hide A185:A242. Otherwise hide all rows that are blank in range A191:A240.
- A251:A300 - If cell A251 is blank, Hide A246:A302. Otherwise hide all rows that are blank in range A251:A300.
Code:
Dim wsMySheet As Worksheet
Dim lngMyRow As Long, unionRng As Range
Application.ScreenUpdating = False
For Each wsMySheet In ThisWorkbook.Sheets
Select Case wsMySheet.Name
Case Is = Sheet3
.Range("A11:A60", "A71:120", "A131:A180", "A191:A240", "A251:A300").EntireRow.Hidden = False
For lngMyRow = 11 To 60
If Len(.Range("A" & lngMyRow)) = 0 Then
If Not unionRng Is Nothing Then
Set unionRng = Union(unionRng, .Range("A" & lngMyRow))
Else
Set unionRng = .Range("A" & lngMyRow)
End If
End If
Next lngMyRow
End With
End Select
If Not unionRng Is Nothing Then unionRng.EntireRow.Hidden = True
Set unionRng = Nothing
Next wsMySheet
Application.ScreenUpdating = True
[FONT=inherit]End Sub[/FONT]