Disabling and Enabling a Userform

java568

New Member
Joined
Aug 3, 2011
Messages
11
If I do the following when a button clicks in a userform on Excel '07:

Code:
Me.Enable = False
 
'-----any type of code or even blank----'
 
Me.Enable = True '<---- Does not work

How come the second enable doesn't work? This seems to be the case regardless of the type of code between the two statements.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try loading it first? (not sure tho, come back with feedback)
Code:
Load Me
Me.Enable = True
 
Upvote 0
My experience with userforms is a bit limited but I'll try and help until someone more knowledgable shows up.

Me referrs to the UF itself so if it's not enabled, the Me. wont work and you'd need to use UserForm1. instead of Me. (or whatever you named your form)

Does that help?
 
Upvote 0
What is it you are trying to enable/disable?

You can't enable/disable a userform.
 
Upvote 0
My experience with userforms is a bit limited but I'll try and help until someone more knowledgable shows up.

Me referrs to the UF itself so if it's not enabled, the Me. wont work and you'd need to use UserForm1. instead of Me. (or whatever you named your form)

Does that help?

Are you saying I'd need to re-enable it from outside the scope of the userform? I've already tried using its name instead of me inside the userform, and it still doesn't work. Every other line of code within the userform runs perfectly even when the userform is disabled.
 
Upvote 0
Try loading it first? (not sure tho, come back with feedback)
Code:
Load Me
Me.Enable = True

All this is being run after the userform has been shown, so wouldn't loading it cause an error? Isn't it already loaded?

What is it you are trying to enable/disable?

You can't enable/disable a userform.

There is a userform.enabled property that I can set to true/false. Does this not do what I think it does? I'm basically trying to make it so that the userform cannot be changed while some functions are being run from a different module (these methods use automation and take 5-10s to run each).
 
Upvote 0
Yes there's a Enabled property but you are using Enable.

I actually it was only available in VB6 not VBA - there are a few things like that.

I think CWatts is right - if you've disabled a form, how can it enable itself?

By the way, how would a userform be changed by other code?
 
Upvote 0
Yes there's a Enabled property but you are using Enable.

I actually it was only available in VB6 not VBA - there are a few things like that.

I think CWatts is right - if you've disabled a form, how can it enable itself?

By the way, how would a userform be changed by other code?

Those are all typos, it should say "Enabled". Sorry about that.

It should be able to enable itself, considering that it can run all the other code within its macro when it is disabled.

I could enable/disable from the module rather from the userform. That's what I meant by other code.
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,794
Members
452,943
Latest member
Newbie4296

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