[vba]
Sub hide_if_error()
Dim MyCell As Range, Rng As Range
Set Rng = Range("c8:c27")
For Each MyCell In Rng
If MyCell = IsError??? Then
MyCell.EntireRow.Hidden = True
End If
Next MyCell
End Sub
[/vba]
[vba]
Sub hide_if_error()
Dim MyCell As Range, Rng As Range
Set Rng = Range("c8:c27")
For Each MyCell In Rng
If MyCell = IsError??? Then
MyCell.EntireRow.Hidden = True
End If
Next MyCell
End Sub
[/vba]
T-ogether
E-veryone
A-chieves
M-ore
One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.
[vba]
Sub hide_if_error()
Dim MyCell As Range, Rng As Range
Set Rng = Range("c8:c27")
For Each MyCell In Rng
If IsError(MyCell) Then
MyCell.EntireRow.Hidden = True
End If
Next MyCell
End Sub
[/vba]
But hiding errors seems like a bad idea to me.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Same here but as it was requested by the user so I must give it ... How can I apply this to work in multiple worksheets (Sheet20 upto sheet80) in a command buttonOriginally Posted by xld
T-ogether
E-veryone
A-chieves
M-ore
One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.
Same range for each sheet, or different? Set sheets, or variable?
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
same range on each sheet...
T-ogether
E-veryone
A-chieves
M-ore
One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.
[vba]
Sub hide_if_error()
Dim MyCell As Range, Rng As Range
For Each sh In ActiveWorkbook.Worksheets
Set Rng = sh.Range("c8:c27")
For Each MyCell In Rng
If IsError(MyCell) Then
MyCell.EntireRow.Hidden = True
End If
Next MyCell
Next sh
End Sub
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Hi,
I think a loop can be avoided. See
[vba]On Error Resume Next
Range("c8:c27").SpecialCells(xlCellTypeFormulas, 16).EntireRow.Hidden = True
Range("c8:c27").SpecialCells(xlCellTypeConstants, 16).EntireRow.Hidden = True
On Error GoTo 0[/vba]
HTH
Solved
T-ogether
E-veryone
A-chieves
M-ore
One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.
Krishna,
Why not use 'xlErrors' instead of the number 16 (its numeric equivalent) since the term is more discriptive?
[vba]On Error Resume Next
Range("c8:c27").SpecialCells(xlCellTypeFormulas, xlErrors).EntireRow.Hidden = True
Range("c8:c27").SpecialCells(xlCellTypeConstants, xlErrors).EntireRow.Hidden = True
On Error GoTo 0[/vba]
Thanks,
Ron
Windermere, FL
Well, that was recorded macro. Will keep in mind.Originally Posted by RonMcK