Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-10-19
5
Medium Priority
?
696 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

824 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