ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserForm - display text message then run code (https://www.excelbanter.com/excel-programming/276792-userform-display-text-message-then-run-code.html)

Robert[_13_]

UserForm - display text message then run code
 
I have a UserForm which runs some code for around 2 minutes. When the
CommandButton is activated I want a short message to display in a
TextBox on the UserForm throughout the time the code is running.
Even though 'TextBox1.Text = "selection running" is placed at the
beginning the message does not appear until all the process has finished
running.
Grateful for any suggestions.
--
Robert

Bob Kilmer

UserForm - display text message then run code
 
Look at DoEvents.

--
Bob Kilmer


"Robert" wrote in message
...
I have a UserForm which runs some code for around 2 minutes. When the
CommandButton is activated I want a short message to display in a
TextBox on the UserForm throughout the time the code is running.
Even though 'TextBox1.Text = "selection running" is placed at the
beginning the message does not appear until all the process has finished
running.
Grateful for any suggestions.
--
Robert




steve

UserForm - display text message then run code
 
Robert,

One way is to use the Status Bar at the bottom of the screen.
At various places within your code you can set different messages
Application.StatusBar = "Code processing begun"
Application.StatusBar = "2nd message"
......
Application.StatusBar = False ' this resets the Status Bar

Or you can use an extra sheet with a message on it.
In your code - show the window than use
Application.ScreenUpdating = False
to freeze the view (not the code).
Set it back to True at the end of your code (and besure to hide the sheet.

An alternate is to insert the sheet and than delete it. Or create another
workbook with a message page and than close it without saving.
use
Application.DisplayAlerts = False ' reset to true at the end
than close it without saving.

Just a couple of ideas to work with.

Post back if you want more input...

--
sb
"Robert" wrote in message
...
I have a UserForm which runs some code for around 2 minutes. When the
CommandButton is activated I want a short message to display in a
TextBox on the UserForm throughout the time the code is running.
Even though 'TextBox1.Text = "selection running" is placed at the
beginning the message does not appear until all the process has finished
running.
Grateful for any suggestions.
--
Robert




Robert[_14_]

UserForm - display text message then run code
 
In message , Robert writes
I have a UserForm which runs some code for around 2 minutes. When the
CommandButton is activated I want a short message to display in a
TextBox on the UserForm throughout the time the code is running.
Even though 'TextBox1.Text = "selection running" is placed at the
beginning the message does not appear until all the process has
finished running.
Grateful for any suggestions.


Many thanks for the suggestions - DoEvents has solved the problem.
--
Robert


All times are GMT +1. The time now is 04:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com