Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way to select a cell without having to reinvent the
wheel, via a modless form, is to use: Dim myRange as Range Set myRange = Application.InputBox( _ "Select a cell", Type:=8) But if your form is used to do more than just pick a cell, then to prevent code from executing until the OK button is clicked, you can use a public boolean flag and a DoEvent within a Do While loop. In your module's declarations section at the top: Public OKButtonClicked as Boolean In the VBA routine that calls the form: Private MySubroutine() 'some code OKButtonClicked = False frmMyForm.Show Do While Not OKButtonClicked DoEvents Loop 'some more code End Sub And finally in your form's OK button: Private Sub cmdOK_Click() 'Your Code OKButtonClicked = True End Sub Or as an alternate to the boolean flag, I often hide the form after the OK button is clicked, so I might use: frmMyForm.Show Do While frmMyForm.Visible DoEvents Loop 'More code here -----Original Message----- Suppose I want to use a form which prompts the user to select a cell and press an OK buttom on the form when ready. I figure the form must be modeless, but how do I prevent the code following the statement frmMyForm.Show from executing until the OK button on the form has been clicked? TIA, Arne . |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How Email does not need user interaction ? | Excel Discussion (Misc queries) | |||
How do I fill a cell in a user form from a selection on same form? | Excel Discussion (Misc queries) | |||
Interaction of form controls and pictures in Excel 2007 | Excel Worksheet Functions | |||
User form | Excel Discussion (Misc queries) | |||
Modeless userform | New Users to Excel |