locking a button

G

Guest

Guest
I have created a button to take me to anoher sheet, however I only want the button to become active once the value within a cell satisfys certain criteria,ie <>0
Help appreciated cos holding up college assignment!!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I have created a button to take me to anoher sheet, however I only want the button to become active once the value within a cell satisfys certain criteria,ie <>0
Help appreciated cos holding up college assignment!!

Hi,

Are you using the button from View, Toolbars, Forms or View, Toolbars, Control Toolbox? If you're using the second type then doing what you want is fairly easy...

Right click the worksheet tab and choose View Code. Then try something like this:-

Code:
Private Sub Worksheet_Calculate()
CheckA1
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
CheckA1
End Sub

Sub CheckA1()
If Range("A1") <> 0 Then
    Me.CommandButton1.Enabled = True
Else
    Me.CommandButton1.Enabled = False
End If
End Sub

You'll have to change the name of your command button to match the name of yours.

HTH,
D
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,765
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top