Hello,
I would like to hide certain rows in a range of cells using an If statement. Here's the scenario...
In the Column "A", I would like to place a "*" in a cell to indicate that I would like that row to be hidden, then run a VBA code that says "if there's a "*" in that cell, hide that entire row.
I got this to work using 1 cell, but can't get it to happen with a range (i.e. all cells in Column A).
Code that worked with 1 cell:
Sub hide()
If Range("A4").Value = "*" Then
Range("A4").EntireRow.Hidden = True
Else
Range("A4").EntireRow.Hidden = False
End If
End Sub
This is what I've tried to get it to apply to a range, but can't figure it out:
Sub hide()
Dim star As Range
Set star = Range("A4:A7")
For Each Ccell In star
If Ccell.Value = "*" Then
EntireRow.Hidden = True
Else
EntireRow.Hidden = False
End If
Next
End Sub
Any help from the experts?? Thanks in advance!
William
I would like to hide certain rows in a range of cells using an If statement. Here's the scenario...
In the Column "A", I would like to place a "*" in a cell to indicate that I would like that row to be hidden, then run a VBA code that says "if there's a "*" in that cell, hide that entire row.
I got this to work using 1 cell, but can't get it to happen with a range (i.e. all cells in Column A).
Code that worked with 1 cell:
Sub hide()
If Range("A4").Value = "*" Then
Range("A4").EntireRow.Hidden = True
Else
Range("A4").EntireRow.Hidden = False
End If
End Sub
This is what I've tried to get it to apply to a range, but can't figure it out:
Sub hide()
Dim star As Range
Set star = Range("A4:A7")
For Each Ccell In star
If Ccell.Value = "*" Then
EntireRow.Hidden = True
Else
EntireRow.Hidden = False
End If
Next
End Sub
Any help from the experts?? Thanks in advance!
William