Solved

Pause macro for data entry & prompt user with a message to enter the data...

Posted on 2008-10-19
5
684 Views
Last Modified: 2013-11-25
I wrote a series of individual macros in excel that I want to operate sequentially.  I'm ready to compile them into one grand macro, but I need the grand macro to pause while the user enters data into the spreadsheet.  Once the data is entered, I'd like the macro to run through to completion.

Suggestions?
0
Comment
Question by:ronadair
  • 3
5 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
ID: 22754203
Create a new user form with an OK button and the text (in a label):

"Enter the data required for me to continue. Click OK when done."

Split your grand macro into two parts:

Public Sub Grand1()
...
   UserForm1.Show vbModeless
End Sub

Public Sub Grand2()
...
End Sub

In the click handler for the OK button of the user form add this code:

   Me.Hide
   Grand2

Kevin
0
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 22754261
Attached is an example workbook.

Kevin
Q-23828249.xls
0
 
LVL 7

Expert Comment

by:hippohood
ID: 22756510
If you have no need for creaing an extra foorm you may use InputBox function. Below is the sample from MS VBA Help
"Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns a String containing the contents of the text box... If the user clicks OK or presses ENTER , the InputBox function returns whatever is in the text box. If the user clicks Cancel, the function returns a zero-length string ("")."  

Dim Message, Title, Default, MyValue
Message = "Enter a value between 1 and 3"    ' Set prompt.
Title = "InputBox Demo"    ' Set title.
Default = "1"    ' Set default.
' Display message, title, and default value.
MyValue = InputBox(Message, Title, Default)
 
' Use Helpfile and context. The Help button is added automatically.
MyValue = InputBox(Message, Title, , , , "DEMO.HLP", 10)
 
' Display dialog box at position 100, 100.
MyValue = InputBox(Message, Title, Default, 100, 100)

Open in new window

0
 

Author Closing Comment

by:ronadair
ID: 31507670
Thanks... the procedure works.  One more question:  what code should I enter to exit the sequence so I can start from the beginning in case the data is in some way not ready to enter?
0
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 22760752
hippohood,

That does not solve the problem. VB and Excel message and input boxes are displayed modally which prevents the user from interacting with the worksheet. The Asker specifically stated that he wants the user to interact with the worksheet while the dialog is displayed.

Kevin
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now