1

I have some code to format and edit a spreadsheet all i want is to have the macro pause and ask the individual to enter a reference number into cell A2.

I have tried all sorts of solutions from the www but it seems they are all extremely complicated and way above my level.

Range("A2").Select

Enter reference number

etctetc

Just to have a reference number in a cell and for the rest of the macro to carry on as normal.

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
user2725363
  • 53
  • 1
  • 1
  • 5
  • 3
    Can you not have an InputBox instead of asking user to enter value in a Cell ? – Mikku Aug 08 '19 at 12:58
  • Here is a link on how to make an input box and then put that value in a cell. https://www.excel-easy.com/vba/examples/inputbox-function.html – Jarom Aug 08 '19 at 13:05

1 Answers1

0

The InputBox() is probably the best way to stop a VBA code, when waiting for user input. This is a simple demo. concatenating some numbers with the input from the box:

enter image description here

And after entering "tralala":

enter image description here

Option Explicit

Sub TestMe()

    Dim i As Long
    Dim ii As Long
    For i = 1 To 10
        For ii = 1 To 10
        Worksheets(1).Cells(ii, i) = i + ii
        Next
    Next

    Worksheets(1).Range("A2") = InputBox("Please enter some value in range A2")

    For i = 1 To 10
        For ii = 1 To 10
        Worksheets(1).Cells(ii, i) = i + ii & Worksheets(1).Range("A2")
        Next
    Next


End Sub
Vityata
  • 42,633
  • 8
  • 55
  • 100