Excel Opens to Userform and then shuts off

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
Hello All-

Everyone has been fantastic helping me build (and learn) VBA on this new workbook. It's been great- now I've run into an issue that i don't readily see.

I have 5 userforms. Userforms 1, 2, and 3 open (Workbook_Open) based on one of three names of the workbook- Irregardless of which userform is used, they all have a button to choose "Developer" which opens Userform 5. Userform 5 has two buttons, one will ask for a password to show sheet1, the other just shows sheet2 (no password).

Coding for userform 5 is shown below. It seems when i open excel, the green mini excel window opens, loads, then opens the main window (workbook) for half a second before going to userform1(based on name- does this for any of the first 3 userforms). Once I click the appropriate button, the next userform will open (code below) and after selecting EITHER of its buttons, the workbook flashes behind again for a second and then excel is gone. Any ideas why excel is gone? Any way I can also stop the main workbook window from opening for that brief second before the first userform opens.

Code:
Private Sub CommandButton1_Click()
ThisWorkbook.Sheets("Ports").Activate
Sheets("Notes").Visible = True
Application.Visible = True
Unload Me
End Sub


Private Sub CommandButton2_Click()
mypass = Application.InputBox("Enter Password", "The Coding Sheets")
If mypass = "1234567890" Then
Sheets("Developer").Visible = True
Sheets("Notes").Visible = True
Application.Visible = True
Unload Me
End Sub
 
You don't need to keep coding application.visible = false if it's already false. Anyways, you are coding to show userform before unloading the current userform ie. I think the unload Me then refers to the usderform you just opened. There's several places in the code that you have done this. Here's the userform1 example...
Code:
Private Sub CommandButton1_Click()
 Call VoyageSpecifics
 Unload Me
 UserForm4.Show
 End Sub

Private Sub CommandButton3_Click()
 Unload Me
 UserForm5.Show
End Sub
If excel is present as a process in the task manager then the wb is open and just invisible. Trial temporarily removing all of the visble/invisible stuff and see if your code works as U want. Then add the visible/invisible stuff. Dave
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Fantastic! It worked. So interesting pieces- every user form would load so the unload me parts weren’t “correct” but they weren’t the problem. Moving/deleting the visible pieces did it. Thanks!!!
 
Upvote 0
This thing runs pretty well now- like it’s own app going. The only other question I could ask- there’s a “split second” when starting that it takes for the excel to open the workbook then hide it as it goes to the first user form. On the machine that this is designed to run on, it’s noticeably longer. Is there any code to speed this up. I know by disabling calcs, events, screen updating, etc my sheet formatting macros runs so much smoother and then I re enable at the end.
 
Upvote 0
Maybe slow things down? This code before the show userform (or maybe before the invisible code thing?). The user waits a tiny bit longer while the code executes but no flicker (maybe)? HTH. Dave
Code:
Application.Wait (Now + TimeValue("0:00:01"))
ps anything I've read about flicker resolution has to do with getting rid of activation in your code
 
Last edited:
Upvote 0
Unfortunately I think it's just based on load time of Excel. I did notice, playing tonight, that the Windows 7 Computers that will be running this workbook (and use Excel 2010 or 07) start it faster than Excel 16 on the newer (and much faster machine) and the Excel 2016 has a longer loading startup time.
 
Upvote 0
Thanks for the update. I too hate the long loading time of XL 16... very annoying. Have a nice day. Dave
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,189
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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