View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default How do I hide a command button based on a condition?

Hi

Copy this event in the sheet module
I use a button with the name CommandButton1 and E27 is a formula


Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Target.Cells.Count 1 Then Exit Sub
On Error GoTo EndMacro
If Not Target.HasFormula Then
Set rng = Target.Dependents
If Not Intersect(Range("E27"), rng) Is Nothing Then
If Range("E27").Value 0 Then
ActiveSheet.Shapes("CommandButton1").Visible = True
Else
ActiveSheet.Shapes("CommandButton1").Visible = False
End If
End If
End If
EndMacro:
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


wrote in message oups.com...
Hi everybody,
Nice forum. I have read over the hide command button responces but I
simply cannot follow the advice because I guess its to far over my
head. Can anybody please explain to me how to hide a command button
when a cell ( say E27 ) is 0 but as soon as it turns to 1 (through a
formula) a command button will appear in the sheet and allow a user to
launch a macro to save the data (the button will run a macro that
copies data to a different part of the spreadsheet); after the macro
has run I would like the button to hide again.
I have tried various examples but I guess I am putting the samples in
the wrong places ( modules or microsoft excel objects).
I have spent ~6 hours on this one little issue and it is driving me
crazy.
Thanks for any help,
rattman

p.s. If you write the instructions for a 4th grader maybe I will
understand it? :)