Unload Me does not work???

TAPS_MikeDion

Well-known Member
Joined
Aug 14, 2009
Messages
622
Office Version
  1. 2011
Platform
  1. MacOS
Hi everybody,
Has anyone run into a problem where Unload Me doesn't work? I have a WHOLE lot of code, so I'm hoping to figure this out without having to swamp everyone with a ton of code.

Here's the pieces...

In Userform_Initialize:
Code:
 If Not zMatch Then
     Application.ScreenUpdating = True
     Unload Me
 End If

zMatch does = False, so it proceeds to the Unload Me line.

It then jumps from the Unload Me line of code to UserForm_QueryClose, which simply calls the CLOSE button code:
Code:
Call CommandButton1_Click

Call CommandButton1_Click is the only line of code in UserForm_QueryClose.

In CommandButton1_Click, the very first line is:
Code:
If Initializing Then Exit Sub

Initializing is True, so it exits CommandButton1_Click and returns to Userform_Initialize. However, after it returns it continues on to the next line of code (which is End If) instead of unloading the form. It then continues through the remainder of the Userform_Initialize code.

Any ideas???

Thanks!

-Mike
 
Yes.

Code:
Private Sub CommandButton1_Click()
    If Initializing Then Exit Sub
    
    Application.ScreenUpdating = False

There is more code after Application.ScreenUpdating = False, but it doesn't get that far since Initializing = True.

Exit Sub returns it to UserForm_QueryClose
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Nevermind guy's, it went WAY back to before the userform was loaded.

Thanks for the help!!!
 
Upvote 0

Forum statistics

Threads
1,216,092
Messages
6,128,782
Members
449,468
Latest member
AGreen17

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