ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add text per user input (https://www.excelbanter.com/excel-programming/440372-add-text-per-user-input.html)

BlueAngel

Add text per user input
 
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

Gord Dibben

Add text per user input
 
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

On Mon, 8 Mar 2010 07:30:01 -0800, BlueAngel
wrote:

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




All times are GMT +1. The time now is 04:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com