In a standard code module use
Sub ButtonState()
Dim shpPressedButton As Shape
Dim lngIndex As Long
Dim lngID As Long
Set shpPressedButton = ActiveSheet.Shapes(Application.Caller)
lngID = CLng(Replace(shpPressedButton.Name, "Button ", ""))
If lngID > 4 Then
' hide
For lngIndex = 8 To 5 Step -1
If ActiveSheet.Shapes("Button " & lngIndex).Visible Then
ActiveSheet.Shapes("Button " & lngIndex).Visible = False
Exit For
End If
Next
Else
For lngIndex = 5 To 8
If Not ActiveSheet.Shapes("Button " & lngIndex).Visible Then
ActiveSheet.Shapes("Button " & lngIndex).Visible = True
Exit For
End If
Next
End If
End Sub
Assign macro to all buttons.
in Thisworkbook object use
Private Sub Workbook_Open()
Dim lngIndex As Long
With Worksheets("Ark1")
For lngIndex = 5 To 8
.Shapes("Button " & lngIndex).Visible = False
Next
End With
End Sub
to hide button 5 thru 8 on openning
Bookmarks