Total n00b when it comes to writing Macros. The problem is I need a my Macro to select a cell, then bring up an input box. The user enters there acc number in to the box and it is displayed in the active cell with an * at the end. The macro then takes a new line and should loop the input box again until the user enters stop (I'd prefer they just had to click on cancel). Here is my code:
Sub AddAcc()
' Select first cell for data to be entered.
Sheets("Macro Data").Select
Range("A6").Select
' Request account number.
Dim Acc As String
Do Until Acc = "Stop"
Acc = Application.InputBox(Prompt:="Please input the account number.", Title:="Account Number", Default:="Account Number here")
If Acc = "Account Number here" Then
Exit Sub
Else
Select Case Acc
Case "" & Acc & ""
' Input account number in to Active Cell followed by an "*" and take new line.
ActiveCell.FormulaR1C1 = "" & Acc & "*"
Application.SendKeys ("{ENTER}")
End Select
End If
Loop
End Sub
Please note that after the data is input into the active cell, a new line is taken. However with this loop in place, it just inputs the number without taking a new line and doesn't bring the input box back up either.
Any help appreciated!

New Topic/Question
Reply




MultiQuote




|