Pause in a macro

  • Thread starter Thread starter David McRitchie
  • Start date Start date
D

David McRitchie

Hi Nadeem,

InputBox will do what you ask, all Excel processing
is suspended until replied to. See HELP.
Try to always supply a default value.

Example on my insrtrow.htm page.
 
Nadeem Shafiullah said:
Hi

I want my macro to pause (ask for manual entry) for a while and execute
remaining commands when the value is provided.


thanks in advance
needed

Use an InputBox.

Dim yourValue As String
yourValue = InputBox("Enter a value", "Input Box Caption")
MsgBox yourValue


An InputBox will until a value is entered, then the macro continues.
 
Hi

I want my macro to pause (ask for manual entry) for a while and execute
remaining commands when the value is provided.


thanks in advance
needed
 
HI Merlin
Many thanks for help.
However I am not very familiar with VBA. So can u send the complete script
which I could copy and paste in my script editor.

thanks in advance
Nadeem
 
Nadeem

Here is a macro that has three input boxes.

Sub ColorEveryNthRow()
Dim Rng As Range, i As Integer
Dim prng As Range
Dim startrow As Range
Dim everywhich as Integer
Dim numbrows as Integer
With ActiveSheet
On Error GoTo endall
Set startrow = Application.InputBox(prompt:= _
"Select Row to Start From", Type:=8)
Set Rng = startrow.Cells(1, 1)
everywhich = InputBox("How far apart")
numbrows = InputBox("How many times")
For i = 1 To numbrows - 1
Set prng = Union(Rng, Rng.Offset(everywhich * i, 0))
prng.EntireRow.Interior.ColorIndex = 3
Next
End With
endall:
End Sub

Note: Application.InputBox allows selecting a row with the mouse

The InputBox alone requires manual entry.

Gord Dibben Excel MVP
 
Nadeem Shafiullah said:
Hi

I want my macro to pause (ask for manual entry) for a while and execute
remaining commands when the value is provided.


thanks in advance
needed
 
Are you talking about using an InputBox for user input? If not, use the
Stop method to stop your code. If so, here's an example ..

Sub FooFoo()
dim strInput as String
'code
'more code
strInput = Inputbox("Enter your string:")
if strInput = vbNullString Then exit sub 'if you want
MsgBox "You entered:" & vbCrlf & strInput
End sub
 
Back
Top