View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_2272_] Rick Rothstein \(MVP - VB\)[_2272_] is offline
external usenet poster
 
Posts: 1
Default Hide Autoshape based on Cell Value

Does this change if E5 contains a formula?

Nope! That is a completely different problem. Replace the code I posted
earlier with this code instead...

'********** START OF CODE **********
Dim LastValueInE5 As Double

Private Sub Worksheet_Activate()
LastValueInE5 = Worksheets("Sheet1").Value
End Sub

Private Sub Worksheet_Calculate()
If Range("E5").Value < LastValueInE5 Then
ActiveSheet.Shapes("change").Visible = Range("E5").Value < 0
End If
LastValueInE5 = Range("E5").Value
End Sub
'********** END OF CODE **********

Rick


"tomic" wrote in message
...
Thanks for the quick response.

Does this change if E5 contains a formula? It's working if I enter a zero
into the cell, but if I have a formula in the cell, and the formula
returns a
zero, it doesn't seem to work?

"Rick Rothstein (MVP - VB)" wrote:

Right-click the "Flow Rates" worksheet tab, select "View Code" from the
popup menu that appears and then copy/paste this code into the code
window
that appeared...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$E$5" Then
ActiveSheet.Shapes("change").Visible = Target.Value < 0
End If
End Sub

Rick


"tomic" wrote in message
...
I've tried several things, based on some other posts here, but haven't
been
successful in getting this to work.

I would like to hide an autoshape, named "Change" based on the value of
a
cell "E5" in a worksheet named "Flow Rates". Basically, if E5 = 0, I
don't
want the user to see this autoshape.

Any help would be appreciated. I have a feeling this is fairly simple,
but
as my VB knowledge is fairly limited, I haven't been able to figure it
out.

Thanks.