![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 4
|
How do I write a macro which goes to a cell then waits for the "enter key" to be pressed before continuing on with the macro?
|
|
|
|
|
|
#2 |
|
Board Regular
Join Date: May 2002
Location: Milton Keynes - UK
Posts: 95
|
Would a message box do the trick?
That would stop the macro, and the 'Ok' button clicks when the enter key is pressed...
__________________
.:wob:. |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
What about splitting the macro up. Have the first part run and then stop. Then have the rest of the macro in the click event of a command button.
__________________
Kind regards, Al Chara |
|
|
|
|
|
#4 |
|
New Member
Join Date: May 2002
Posts: 1
|
I am interested to know other ways to do this too, except I want to write a macro that stops at about 15 cells and waits for data input.
|
|
|
|
|
|
#5 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Quote:
__________________
Kind regards, Al Chara |
|
|
|
|
|
|
#6 |
|
Board Regular
Join Date: May 2002
Posts: 809
|
There are Worksheet.Change and Worksheet.SelectionChange events, those could be used.
I would think something along these lines: Restrict the ScrollArea of the worksheet to only the cells you want entered and filled. Have a counter set to zero. Have the event (your choice) qualify the entries; this may be rather easy, or rather hard, I don't know what you are looking for. You might need to loop through something like: Restrict the selection area to a specific cell Upon entry, analyze the response, and act accordingly Restrict the selection area to the next specific cell Upon entry, analyze the response, and act accordingly You get the idea I am currently playing with a sheet to determine how to do this. So far.... Set Worksheet.EnableSelection = xlUnlockedCells That will keep you from selecting locked cells. [ This Message was edited by: stevebausch on 2002-05-23 15:57 ] |
|
|
|
|
|
#7 |
|
MrExcel MVP
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
|
In the worksheet that you want to "move and Pause" in drop this code.
Code:
Private Sub Worksheet_Change(ByVal Target As Range) Call Module1.GetDataAndWaitAtNextCell(Target.Address) End Sub Code:
Public Sub GetDataAndWaitAtNextCell(Address)
Select Case Address
Case "$A1"
Sheets(1).Range("$A3").Select
Call ProcessStuff(Sheets(1).Range("$A1").Value)
Case "$A3"
Sheets(1).Range("$A5").Select
Case "$A5"
Sheets(1).Range("$A7").Select
End Select
End Sub
Weird ... when I enter the code to this website the address gets changed ... it looses the $Number part of the address ... anyway I think you see what I'm doing [ This Message was edited by: Nimrod on 2002-05-23 18:40 ] [ This Message was edited by: Nimrod on 2002-05-23 18:42 ] |
|
|
|
|
|
#8 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Hi All here is another way to do it.
Useing Onkey to restart your Macro as Al has suggested...ie running 2 parts. Note All suggestions sound GOOD to me this is just another way.... Sub TestPause() Dim x As Integer Dim y As Integer For x = 1 To 200 For y = 1 To 10 Cells(x, y) = x * y Next Next '// goto the cell you want Application.Goto [A10], True '// Set the Enter key up to run the next routine Application.OnKey "{ENTER}", "Continue" End Sub Sub Continue() '// Disable the Onkey now Application.OnKey "{ENTER}" MsgBox "The rest of my code is running!" & vbCr & _ "Try the Enter key NOW" End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|