Excel VBA: is it possible to create a macro that types a character into a cell and lets the user continue typing?

Viewed 96

I'd like to write a macro that when invoked thru a button, inserts a character into a cell and keeping the focus on that cell, lets the user typing. For example, after the button is pressed, in the cell A1 the letter "A" is put and the user can type directly after the "A". When the user presses enter the cell stores "A" plus whatever the user wrote.

EDIT:

For my case, I'm trying out Gary's Student's approach. I actually want to put the sign "=" to let the user enter more easily an arithmetic expression. I wrote this function that works but I would like to clear the cell in case the user presses the button the triggers the function but just presses enter without entering anything at the right of "=". This part of my function does nothing. Could you guys help me out?

Sub UserFormula()

CurrentCell = ActiveCell.Address
CurrentCellValue = ActiveCell.Value

If CurrentCellValue = "=" Or Not IsNumeric(CurrentCellValue) Then CurrentCellValue = ""

ActiveSheet.Range(CurrentCell).Value = "=" & CurrentCellValue
ActiveSheet.Range(CurrentCell).Select
Application.SendKeys "{F2}"

'THIS DOESN'T WORK:
If ActiveCell.Address <> CurrentCell Then    'user pressed enter and moved to next cell
     
    CurrentCellValue = ActiveSheet.Range(CurrentCell).Value 'read again the value
    
    If CurrentCellValue = "=" Or Not IsNumeric(CurrentCellValue) Then
        CurrentCellValue = ""
        ActiveSheet.Range(CurrentCell).Value = CurrentCellValue
    End If
End If

End Sub

1 Answers

This will place A in cell A1 and leave the editing state with the cursor after the A:

Sub PushMe()
    Range("A1").Value = "A"
    Range("A1").Select
    Application.SendKeys "{F2}"
End Sub
Related