disable macros in a worksheet

G

Gordon

Hi...

I have a workbook with 10 sheets with 15 buttons (with macros) per sheet. Is
it possible to enable/disable these buttons based on a a value entered in a
cell?

e.g. If the user enters a value into cell A1 he can begin to navigate the
workbook using the buttons/macros?

Someone must be clever out there.

Thanks

G
 
J

Jim Thomlinson

You need to add a validation routinte to each command button that checks the
value of cell A1. Depending on the value exit sub or continue. There is no
silver bullet on this one...
 
G

Gordon

Hi...Where do I find the validation option in the code settings for the
command button?
 
R

Rick Rothstein

You did mean CommandButton when you said "button", right?

Which "buttons" did you use... the ones from Form's toolbar or the Control
Toolbox toolbar?
 
J

Jim Thomlinson

You build it yourself

Private Sub CommandButton1_Click()
If Not IsGoodToGo Then Exit Sub
End Sub

Public Function IsGoodToGo() As Boolean
IsGoodToGo = False
If Range("A1").Value = "Something" Then IsGoodToGo = True
End Function
 
O

Orion Cochrane

I was able to do the following with CommandButton1 using Control Toolbox and
Sheet1 Object:
Private Sub CommandButton1_Click()
Range("A2").Value = "Cochrane"
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = "Orion" Then
CommandButton1.Enabled = True
Else: CommandButton1.Enabled = False
End If
End Sub

I tested it and it works. Substitute with your CommandButton1_Click actions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top