Solved

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

Posted on 2008-10-19
5
682 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
Comment Utility
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)
Comment Utility
Attached is an example workbook.

Kevin
Q-23828249.xls
0
 
LVL 7

Expert Comment

by:hippohood
Comment Utility
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
Comment Utility
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)
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
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 in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

763 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

7 Experts available now in Live!

Get 1:1 Help Now