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
Dave Peterson - 12 Apr 2008 01:00 GMT
Nope.
Formulas can only return values to the cell that they're in.
> Can a HIDE Row(s) or Column(s) statement be imbedded in an IF statement?
>
[quoted text clipped - 6 lines]
> Thank You!
> Wayne

Signature
Dave Peterson
Pete_UK - 12 Apr 2008 01:02 GMT
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
> Can a HIDE Row(s) or Column(s) statement be imbedded in an IF statement?
>
[quoted text clipped - 6 lines]
> Thank You!
> Wayne
Shane Devenshire - 12 Apr 2008 04:41 GMT
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
> Can a HIDE Row(s) or Column(s) statement be imbedded in an IF statement?
>
[quoted text clipped - 6 lines]
> Thank You!
> Wayne
Mbt6 - 12 Apr 2008 09:37 GMT
You could use conditional formatting in the row you want to hide. IF A1=B1
change font to white. It doesn't really hide the full row, but it would make
it not visible....it's a crappy work around, but it might work.
> Can a HIDE Row(s) or Column(s) statement be imbedded in an IF statement?
>
[quoted text clipped - 6 lines]
> Thank You!
> Wayne
WGD - 12 Apr 2008 20:38 GMT
Appreciative! Thought I would give it a whirl! Tks. Wayne
> Can a HIDE Row(s) or Column(s) statement be imbedded in an IF statement?
>
[quoted text clipped - 6 lines]
> Thank You!
> Wayne