View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default disable pushbutton on spreadsheet

Ps. It's not the caption of the button that's important to the code. It's the
name of the button that's important.

Select the button (right click on it should do fine).

Then look in the Namebox (to the left of the formula bar) to see the name that
the code has to use.

pps. I'd change the caption to something meaningful the user would understand.

Robert Crandal wrote:

I do not use the CommandButton1 on my Sheet1. I am just using a regular
push button on top of my sheet which has the caption of "Button 1".

I tried using your code below, but it did not seem to work. I got a
subscript out of range error. Does my button caption need to be

"button 1" or "button_1" or something else?? I don't know what I'm
doing wrong.

thank you

"Dave Peterson" wrote in message
...

Option Explicit
Private Sub CommandButton2_Click()
'cancel button on the userform
ThisWorkbook.Worksheets("sheet1").Buttons("button 1").Enabled = True
Unload Me
End Sub
Private Sub UserForm_Initialize()
ThisWorkbook.Worksheets("sheet1").Buttons("button 1").Enabled = False
End Sub


--

Dave Peterson