Add text per user input

B

BlueAngel

I would like to have a macro that when run would prompt the user to select
rows of data and then prompt the user to input information for the cell. The
new information would be appended to the beginning of cell "D" for each row
selected. There will be 4 digits in each cell "D". Therefore, if "D"
currently contains 1234 and the user selects this cell, runs the macro and
enters 555, then cell "D" woul display 5551234. Can someone help?

Thanks in advance,

BlueAngel
 
G

Gord Dibben

Sub Add_Text_Left()
Dim Cell As Range
Dim moretext As String
Dim thisrng As Range
On Error GoTo endit
Set thisrng = Range(ActiveCell.Address & "," & Selection.Address) _
.SpecialCells(xlCellTypeConstants, xlTextValues)
moretext = InputBox("Enter your Text")
For Each Cell In thisrng
Cell.Value = moretext & Cell.Value
Next
Exit Sub
endit:
MsgBox "only formulas in range"
End Sub

Assumes user will select a range of cells prior to running.


Gord Dibben MS Excel MVP
 

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