Message box to wait for calculation to complete

Sheripres

Board Regular
Joined
Sep 7, 2011
Messages
91
Hello:

I would like to create (hopefully) an Event Code that once data is put in cell B2, a message box would pop up to tell end user to "wait for calculation to complete" and once it is done, it will read, "calculation is completed".

This form I created takes about 10 to 15 seconds for it to go through 70,000 rows of data and I don't want the end user to interrupt that code.

Thank you,

Sheri
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Not sure about this but you can try checking periodically the Application.Ready property until it returns TRUE
 
Upvote 0
Why not put the messages into the exisitng code......If you're not sure how to do that, post the code back here !!!
 
Upvote 0
I usually handle this with forms instead of message boxes. That way the macro can continue to run in the background while the form is displayed.

Create 2 similar forms. 1 will say that the process has started and to please wait. The other will say the process is complete. At the beginning of your code, show the first form. Run the rest of your code. At the end of the code, hide form 1, and show form 2, with a command button to hide the form.

Alternatively instead of a 2nd form, the process complete dialogue could be in the form of a message box.
 
Upvote 0
Thank you for all the responses.

I do not have any macro that is running first. I have this formula running for 192 rows across 17 columns:

=IF(ISERROR(INDEX('raw master data'!$A$1:$AG$70000,SMALL(IF('raw master data'!$A$1:$A$70000=$C$2,ROW('raw master data'!$A$1:$A$70000)),ROW(2:2)),10)),"",
INDEX('raw master data'!$A$1:$AG$70000,SMALL(IF('raw master data'!$A$1:$A$70000=$C$2,ROW('raw master data'!$A$1:$A$70000)),ROW(2:2)),10))

<tbody>
</tbody>

The data it is looking up on the Raw Master Data file is 69,922 rows. So, once the person types in there data in B2, it has to calculate and it takes a while and I don't want them to accidentally click on the sheet until it is done calculating.

I never worked with Forms before. I can do research on that. I will look at Application.Ready too.

Thank you!

Sheri
 
Upvote 0
What about code that would disable calculation before open, then add a button to calculate and have the form visible during the calculation instructing the user to please wait during processing. Once calculation is complete the form hides?
 
Upvote 0
That is a great idea! Can you help me with that code? As I mentioned, I never worked with forms before. I did download basics on how forms work.

If it is too much to ask for the code, I understand. I am sure there is something out there on the net that I can "Google".

Thank you so much!:)
 
Upvote 0
No problem. I can help. It's 11pm here in Singapore so I'll look into it in about 9 hours. Stay tuned.
 
Upvote 0
1. Open the VBA editor by hitting ALT+F11.
2. Navigate to your workbook in the project explorer in the left pane and click the name of your workbook to activate it.
3. Click INSERT in the menu bar at the top of the VBA window and choose UserForm.
4. Add a text box to your userform that says something like "Please wait while the calculations are being performed. This window will close automatically when it is OK to proceed". This can really be anything you'd like it to say.
5. Once you have created the form, in the project explorer on the left, navigate to your workbook and on the "ThisWorkbook" object, right click and select "View Code"
6. In this window that opens up, paste the following code:
Code:
Private Sub Workbook_Open() 
    Dim MyArray As Variant
    Dim wsht As Worksheet
    Set MyArray = Sheets(Array("Sheet1", "Sheet2")) 'modify this based on the name of the sheets you need to disable auto calculation for, if you need to only do it to 1 sheet, that will be ok too.
    For Each wsht In MyArray
        With wsht
            Application.Calculation = xlCalculationManual
        End With
    Next wsht
End Sub
7. Modify that code based on the sheet names of the sheets you need to disable calculation for. See my comment in the code itself.
8. Click INSERT again in the menu and choose MODULE.
9. In the new window that opens, paste this code:
Code:
'---------------------------------------------------------------------------------------' Procedure    : Calc_and_ShowForm
' Author       : Michael Barry
' Date         : 7/7/2015
'
' Purpose      : This procedure will show a form which instructs the user to please wait while calculations are being performed.
'
' Instructions : Run this via a button to perform calculation.  After it completes, calculation will be turned back to manual.
'---------------------------------------------------------------------------------------
'
Sub Calc_and_ShowForm()




UserForm1.Show False
Application.Wait (Now + TimeValue("0:00:01"))


Application.Calculate
If Not Application.CalculationState = xlDone Then
    DoEvents
End If


UserForm1.Hide
Application.Calculation = xlCalculationManual


End Sub
10. Add a button to your worksheet and assign this macro to it (Calc_and_ShowForm).

Now, when you open the workbook, auto calc will be disabled on the worksheet. You will initiate a calculation by clicking the button, at which point your form will pop up, tell the user the calculations are being performed (which will be happening in the background) and once it has completed, the form will go away and calculation will be set back to manual.

I have included a link to a file that has all of this done already if it helps you (as you may not be familiar at all with VBA and even with the instructions above it may be difficult). Not sure if it will be easy for you to import your existing data into this workbook or not though.

https://www.dropbox.com/s/s8plhavbgwzpt6j/Sheripres_FormWhileCalculating.xlsm?dl=0
 
Upvote 0

Forum statistics

Threads
1,215,637
Messages
6,125,963
Members
449,276
Latest member
surendra75

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