Object variable or With block not defined

Cunning

Board Regular
Joined
Jul 8, 2008
Messages
62
I keep getting runtime error 91 Object Variable or With block not defined for the following VBA.

Private Sub CommandButton1_Click()

ActiveSheet.Unprotect Password:=TextBox1.Text

Unload Me

End Sub

How can I rectify this?
 
Sorry Andrew, I realised that was a bit of an erroneous statment as soon as I sent it.

The userform is very basic, with a text box (textbox1) and a command button (OK).

It has to be a userform as obviously the password needs to be hidden characters and I'd rather people got access via the click of a button on the sheet rather than trawling through the menu's as the password resets on sheet activation and it could become too cumbersome.
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Well as I said I can't reproduce that error, and I can't imagine why it would occur on that line for one user but not others.
 
Upvote 0

Forum statistics

Threads
1,224,612
Messages
6,179,890
Members
452,948
Latest member
Dupuhini

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
Back
Top