Hide Question

  • Thread starter Thread starter WGD
  • Start date Start date
W

WGD

Can a HIDE Row(s) or Column(s) statement be imbedded in an IF statement?

For instance, what might be the real way to write what I hope is obvious in
the following?

=IF(A1=B1,"Yes",Hide Row x) where if A1=B1, then Yes is shown, if not
equal, then Row x is hidden. (Gulp!)

Thank You!
Wayne
 
You can't use a formula to hide a row or column (or to change formatting in
any way) - you would need to use a macro to do that.

Hope this helps.

Pete
 
Hi,

Of course you can add VBA which is triggered by the results of a
calculation. For example if you put the formula in cell C3 of Sheet1 and
named that cell myCell and you want to hide row 2 if the formula returns
anything other than "Yes", then the following code would be added to the
Sheet1 code module:

Private Sub Worksheet_Calculate()
If Range("myCell") = "Yes" Then
Rows("2:2").EntireRow.Hidden = False
Else
Rows("2:2").EntireRow.Hidden = True
End If
End Sub

Cheers,
Shane Devenshire
Microsoft Excel MVP
 
Back
Top