Check to see if a certain cell is empty or blank


Posted by John M. on December 19, 2000 4:20 PM

I wrote a macro to check range("H78:R78") to see if all of them were Blank, if this is true then I want to hide row("77:86")
But if one of the cell contain a value the hide should be false.
I use the following macro.
Sub HideRows()
Dim Cell As Range
For each Cell In Range("H78:R78")
If Cell.value = "" Then
Rows("77:86").Select
Selection.EntireRow.Hidden = True
Esle
Selection.EntireRow.Hidden = False
End If
Next
End Sub
When I run this it Does not work as I want it to be.
I try some other way and it give me an error message type mistch '13'.
Some body please help me. Thanks



Posted by DAVID on December 19, 2000 11:50 PM


you macro appear to only care if the last value is

my suggestion is SOMETHING MORE LIKE


Sub HideRows()

Dim Cell As Range
Dim blnCellHasData As Boolean

For Each Cell In Range("H78:R78")
If Cell.Value = "" Then
'DO NOTHING
Else
blnCellHasData = True
End If
Next

If blnCellHasData Then
Rows("77:86").EntireRow.Hidden = True
Else
Rows("77:86").EntireRow.Hidden = False
End If

End Sub