pausing a macro to input cell contents

B

blipityblap

My first macro using XP, Excel 2003.

During the Recording of a macro, what syntax/keystroke is required to
'pause' a macro so as to allow input of data into a cell address, and then
re-initate continuance of the macro to its next step? I do not want to end
or stop the macro, just pause it automatically to enter data.
 
G

Gord Dibben

Pause for input........................

Sub getuserinput()
'some of your code goes here
usrinput = InputBox("enter a number")
Range("A1").Value = usrinput
'resume rest of code
End Sub

Or if you want to select a cell or range to operate on...........

Sub selectit()
'your code
Set srng = Application.InputBox(prompt:= _
"Select a Range of cells", Type:=8)
'do something with srng
End Sub

Combination of the two above into one...............

Sub selectit()
usrinput = InputBox("enter a string")
Set srng = Application.InputBox(prompt:= _
"Select a Range of cells", Type:=8)
For Each cell In srng
cell.Value = usrinput
Next
End Sub


Gord Dibben MS Excel MVP
 
B

blipityblap

Thank you very much. I now realize I must read a book on Visual Basic in
order to construct an auto-record Excel macro. Likely I'll simply go back to
Quattro Pro which has been working well for 18 years.
 
G

Gord Dibben

Yes, unfortunately you cannot record a macro and get things like InputBoxes.

You have to read a book or look to the VBA Help section of Excel


Gord
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top