invisible button

S

skitek

Guys,

New challange. How to make particular button invisible if it meet
certain criteria (eg. result of a function is 3 then... )
Waiting for Your help (macro)

th
 
A

Andy Brown

Waiting for Your help (macro)

In the worksheet module,

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("B2").Value = 3 Then
CommandButton1.Visible = False
Else
CommandButton1.Visible = True
End If
End Sub

Rgds,
Andy
 
D

Don Guillett

Try this.Sub hideshapetruefalse()
If Range("a3") > 3 Then
x = msoFalse
Else
x = msoTrue
End If
ActiveSheet.Shapes("Rectangle 1").Select
With Selection.ShapeRange
..Fill.Visible = x
..Line.Visible = x
End With
Range("a3").Select
End Sub

It could be a worksheet_change event using a3 as the target to make it
automatic. Right click sheet tab>view code>copy/paste this. Now when a3
changes the macro will auto execute

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$3" Then Exit Sub
If Target > 3 Then
x = msoFalse
Else
x = msoTrue
End If
ActiveSheet.Shapes("Rectangle 1").Select
With Selection.ShapeRange
..Fill.Visible = x
..Line.Visible = x
End With
Target.Select
End Sub
 
D

Don Guillett

After reading Andy's, I realized mine can also be:

If Range("a3") > 3 Then
ActiveSheet.Shapes("Rectangle 1").Visible = False
Else
ActiveSheet.Shapes("Rectangle 1").Visible = True
End If

--
Don Guillett
SalesAid Software
[email protected]
Don Guillett said:
Try this.Sub hideshapetruefalse()
If Range("a3") > 3 Then
x = msoFalse
Else
x = msoTrue
End If
ActiveSheet.Shapes("Rectangle 1").Select
With Selection.ShapeRange
.Fill.Visible = x
.Line.Visible = x
End With
Range("a3").Select
End Sub

It could be a worksheet_change event using a3 as the target to make it
automatic. Right click sheet tab>view code>copy/paste this. Now when a3
changes the macro will auto execute

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$3" Then Exit Sub
If Target > 3 Then
x = msoFalse
Else
x = msoTrue
End If
ActiveSheet.Shapes("Rectangle 1").Select
With Selection.ShapeRange
.Fill.Visible = x
.Line.Visible = x
End With
Target.Select
End Sub
 
Top