Thread: WHY?
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default ANOTHER WHY?

If you are using Excel 97, change the takefocusonclick property of the
commandbutton to false.

--
Regards,
Tom Ogilvy

DENNIS wrote in message
...
Thanks I'm not sure what I was doing wrong but that bit
works now.

There is another problem though

On sheet1 i have a button.
This button produces a userform, which in turn has a
button on it.
When the button on the userform is pressed a message box
appears with Yes and No.
If Yes is clicked then I want the worksheet to be
unprotected, but it comes up with a run time error.

Code as follows

'on userform
Sub commandbutton1_Click()
If msgbox("Unprotect sheet?", vbyesno) = vbyes then
worksheets(1).unprotect password:= "HOLIDAY" 'password is
ok
end if

This is really holding me back so any help much
appreciated!
-----Original Message-----
I have a macro call Sub UNPROTECT which unprotects a
worksheet.

I want the user to run this with a button on the

worksheet.
If I use a button from the Forms toolbar it works fine,
but when I call the macro from a button from the
ControlBox toolbar I comes up with a runtime error?

I'd like to use the controlbox button as they are more
versatile and you can change the colour etc.

the unprotect macro code is simply
Worksheets(1).unprotect password:="HOLIDAY"

Thanks in advance
.