Disabling buttons on worksheets using vba

redbull8vodka

New Member
Joined
Sep 23, 2002
Messages
13
Hi there,

Can anyone help me I wish to disable some buttons on a worksheet so to guide the user around the page step by step can anyone help me with the referencing of the button

i.e Worksheet("Main Menu").cmdButton.enabled = False

Cheers
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hey redbull8vodka

The correct code would be :

Code:
Sheets("Main Menu").CommandButton<NumberHere>.Enabled = False

where NumberHere represents the actual CommandButton number.

You can also loop through the controls and disable all those command buttons that are not named "Whatever" using the CmdButton control type i.e

Code:
For Each ctl in Controls
If ctl.Type = CmdButton Then
If ctl.Name <> CommandButton1 Then
ctl.Enabled = False
End If
End If
Next ctl

Try That

anvil19
:eek:
 
Upvote 0
Hey redbull8vodka

The correct code would be :

Code:
Sheets("Main Menu").CommandButton<numberhere>.Enabled = False

where NumberHere represents the actual CommandButton number.

You can also loop through the controls and disable all those command buttons that are not named "Whatever" using the CmdButton control type i.e

Code:
For Each ctl in Controls
If ctl.Type = CmdButton Then
If ctl.Name <> CommandButton1 Then
ctl.Enabled = False
End If
End If
Next ctl

Try That

anvil19
:eek:



hi, can anyone tell me how we suppose to disable the button which we take it from "Form control" i am able to do with activex button but if i take it from Form control i am not able to disable button.

Sub Button1_Click()
Dim b1 As Button
Set b1 = ActiveSheet.Buttons("Button 1")
b1.Font.ColorIndex = 15
b1.Enabled = False

MsgBox "hello"
End Sub


i have written above code and i have try to disable button with changing color but still msgbox "hello" showing every time but "hello" should be show only one time. can anyone help me on this?












</numberhere>
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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