VBA: Regarding Sub Auto_Open()

jase71ds

Board Regular
Joined
Oct 23, 2006
Messages
137
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have an Auto_Open macro that cleans up data before allowing the user to begin. This only takes around 8 seconds, but I wanted to put a message asking the user to please wait a moment while we tidy things up.
What I found is that when I start my Auto_Open macro with MsgBox("Please wait a moment...") - the rest of the code will not run until the user hits "OK"
My preference would be that I could start by showing the message, but that Excel would continue to execute the remainder of the code and not wait until the user clears out the message.

Is this doable?

Thanks for any help.
Jase.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
It is doable - you need to create a userform with say a label or textbox containing the message you want, then show it modelessly at the start. For example:

Code:
With userformname
   .Show False
   .Repaint
End With

The repaint is just there to try and ensure it displays properly before processing the rest of the code.
 
Upvote 0
I'm not familiar with userforms but I'll do some research.
Thanks for the info and code!
 
Upvote 0
Rory,
I created a textbox (went with the default name of TextBox5) and tried the following within Auto_Open()

With TextBox5
.Show False
.Repaint
End With

The code broke at .Show False

Can you (or someone) give a bit more detailed guidance on this?
I'm assuming I create a message (as in a text box or shape) and that, upon open I call it first (letting the user know to be patient). Then I assume at the end of my Auto_Open() code, I close it.
Is this correct?
What am I doing wrong.
Thanks for any help.
Jase.
 
Upvote 0
You have to add a userform to your project, then add the textbox (or a Label) to the userform, and assign your text to that control.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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