disable button in excel spread sheet

vijay2482

Board Regular
Joined
Mar 3, 2009
Messages
142
i have 5 sheets,in one sheet i have 2 buttons.
button 1 - COMPARE
button 2 - CREATE
1)when the spreadsheet is opened,i want the CREATE button to be deactivated/disabled and only COMPARE button should be active.
2)once the COMPARE button is clicked,i want to activate/enable the CREATE button and deactivate/disable the COMPARE button.
how to acquire this?
thank in advance.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

vijay2482

Board Regular
Joined
Mar 3, 2009
Messages
142
yes, its a commandbutton from the excel toolbar and not from the excel userform

is there a way to do this?
 
Upvote 0

Mike Blackman

Well-known Member
Joined
Jun 8, 2007
Messages
2,494
Hi,

Right click on the Sheet Tab and select view code;

Pate this in and add in your current macro's;

Code:
Private Sub CommandButton1_Click()

CommandButton1.Visible = False
CommandButton2.Visible = True

'Your Code

End Sub

Private Sub CommandButton2_Click()

CommandButton1.Visible = True
CommandButton2.Visible = False

'Your Code

End Sub
 
Upvote 0

Mike Blackman

Well-known Member
Joined
Jun 8, 2007
Messages
2,494
Or alternatively;

Code:
Private Sub CommandButton1_Click()

CommandButton1.Enabled = False
CommandButton2.Enabled = True

'Your Code

End Sub

Private Sub CommandButton2_Click()

CommandButton1.Enabled = True
CommandButton2.Enabled = False

'Your Code

End Sub

To actually disable and not hide :)
 
Upvote 0

vijay2482

Board Regular
Joined
Mar 3, 2009
Messages
142
i have different macros to COMPARE and CREATE

should i write this code in the macro or in the codeview of the spreadsheet?
 
Upvote 0

Mike Blackman

Well-known Member
Joined
Jun 8, 2007
Messages
2,494
You can either add the code from yours into the relevant _Click Maro's for there button's or simply call them by replacing;

Code:
' Your Code

With the name or you Macro's.
 
Upvote 0

Forum statistics

Threads
1,191,177
Messages
5,985,132
Members
439,941
Latest member
robertv13

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
Top