Hi,
I'm new to VBA and this forum and wondering if I could request some help please. I am using the code below to unhide rows that contain cells in column H containing the text "Class 1" or "Class 2". I'd like to update the code, or find new code, that only unhides rows where column H contains "Class 1" or "Class 2" and the corresponding cell A in the row contains a 1.
e.g.
- if cell H2 contains "Class 1" or "Class 2" and cell A2=1 then I want row 2 to unhide
- if cell A2 is not equal to 1 I don't want row 2 to unhide whatever is in cell H2
- if cell H2 doesn't contain "Class 1" or "Class 2" I don't want row 2 to unhide whatever is in cell A2.
I don't know where to start with this one!
Any help would be much appreciated
Thank you
Sub macro123()
' hide class 4 and 5 entries
Dim xRg As Range
Application.ScreenUpdating = False
For Each xRg In Range("h107: h350")
If xRg.Value = "Class 1" Then
xRg.EntireRow.Hidden = False
Else
xRg.EntireRow.Hidden = False
End If
Next xRg
For Each xRg In Range("h107: h350")
If xRg.Value = "Class 2" Then
xRg.EntireRow.Hidden = False
Else
xRg.EntireRow.Hidden = False
End If
Next xRg
Application.ScreenUpdating = True
End Sub
I'm new to VBA and this forum and wondering if I could request some help please. I am using the code below to unhide rows that contain cells in column H containing the text "Class 1" or "Class 2". I'd like to update the code, or find new code, that only unhides rows where column H contains "Class 1" or "Class 2" and the corresponding cell A in the row contains a 1.
e.g.
- if cell H2 contains "Class 1" or "Class 2" and cell A2=1 then I want row 2 to unhide
- if cell A2 is not equal to 1 I don't want row 2 to unhide whatever is in cell H2
- if cell H2 doesn't contain "Class 1" or "Class 2" I don't want row 2 to unhide whatever is in cell A2.
I don't know where to start with this one!
Any help would be much appreciated
Thank you
Sub macro123()
' hide class 4 and 5 entries
Dim xRg As Range
Application.ScreenUpdating = False
For Each xRg In Range("h107: h350")
If xRg.Value = "Class 1" Then
xRg.EntireRow.Hidden = False
Else
xRg.EntireRow.Hidden = False
End If
Next xRg
For Each xRg In Range("h107: h350")
If xRg.Value = "Class 2" Then
xRg.EntireRow.Hidden = False
Else
xRg.EntireRow.Hidden = False
End If
Next xRg
Application.ScreenUpdating = True
End Sub