Solved

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

Posted on 2008-10-19
5
687 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
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…

749 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