View Single Post
  #6   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

Is the code in the same workbook as the button?

Is the name of the sheet really Sheet1?

Did you assign the macro to show the userform to the correct button?

If this doesn't help, you may want to share the code you tried, where you put it
and the names of those objects.

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