ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Button on a sheet (https://www.excelbanter.com/excel-programming/415302-button-sheet.html)

ranswrt

Button on a sheet
 
Is there a way to set a button on a worksheet to enable = false like with a
commandbutton on a userform? Will the text lighten to show that it is
disabled?

Rick Rothstein \(MVP - VB\)[_2512_]

Button on a sheet
 
If the button on the worksheet was an ActiveX button control from the
Control Toolbox toolbar, then you could put this in the UserForm's
CommandButton's Click event...

Worksheets("Sheet1").CommandButton1.Enabled = False

Change the worksheet reference and name of the button on the worksheet to
match your actual conditions.

Rick


"ranswrt" wrote in message
...
Is there a way to set a button on a worksheet to enable = false like with
a
commandbutton on a userform? Will the text lighten to show that it is
disabled?



ranswrt

Button on a sheet
 
It was put on with the forms toolbar.

"Rick Rothstein (MVP - VB)" wrote:

If the button on the worksheet was an ActiveX button control from the
Control Toolbox toolbar, then you could put this in the UserForm's
CommandButton's Click event...

Worksheets("Sheet1").CommandButton1.Enabled = False

Change the worksheet reference and name of the button on the worksheet to
match your actual conditions.

Rick


"ranswrt" wrote in message
...
Is there a way to set a button on a worksheet to enable = false like with
a
commandbutton on a userform? Will the text lighten to show that it is
disabled?




Rick Rothstein \(MVP - VB\)[_2513_]

Button on a sheet
 
I think there is a direct way to do what you want with that type of button,
but this kludge method seems to work as a substitute. Put this code line in
the Click event for the CommandButton on your UserForm...

Worksheets("Sheet1").Shapes("Button 1").TextFrame. _
Characters.Font.ColorIndex = 15

Change the worksheet reference and button name to those for your own
condition. Okay, that will change the button's font color to gray. Now, put
this line as the **FIRST** line in the macro assigned to the button

If Sheet1Shapes("Button 1").TextFrame.Characters. _
Font.ColorIndex = 15 Then Exit Sub

Again, change the worksheet reference and button name to those for your own
condition. If the button's font color is color index 15, the assigned macro
will exit before any code is executed... if the color index is any other
value, the macro code will run normally. This duplicates what happens when a
control is disabled and should suffice for your needs.

Rick


"ranswrt" wrote in message
...
It was put on with the forms toolbar.

"Rick Rothstein (MVP - VB)" wrote:

If the button on the worksheet was an ActiveX button control from the
Control Toolbox toolbar, then you could put this in the UserForm's
CommandButton's Click event...

Worksheets("Sheet1").CommandButton1.Enabled = False

Change the worksheet reference and name of the button on the worksheet to
match your actual conditions.

Rick


"ranswrt" wrote in message
...
Is there a way to set a button on a worksheet to enable = false like
with
a
commandbutton on a userform? Will the text lighten to show that it is
disabled?





Rick Rothstein \(MVP - VB\)[_2514_]

Button on a sheet
 
I think there is a direct way to do what you want with that type of button,

That was supposed to say "I **DO NOT** think there is a direct way...

Rick


Randy

Button on a sheet
 
Thanks I think I will switch the buttons to a control button from the toolbox
toolbar.
That seems alot easier.

"Rick Rothstein (MVP - VB)" wrote:

I think there is a direct way to do what you want with that type of button,


That was supposed to say "I **DO NOT** think there is a direct way...

Rick




All times are GMT +1. The time now is 05:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com