Excel prepend character

I have a column of data and would like to prepend the first character with a special character like # or $. Is there any automated way to do this, thanks

column1
data1
data2
data3
data4

I would like for this to become without going to each row.

#data1
#data2
#data3
techdriveAsked:
Who is Participating?
 
nutschConnect With a Mentor Commented:
Formula way:
Create a new column with the formula ="#" & A1
Extend the formula down by a copy paste
Copy the result then paste values over your initial data
Remove the temporary column

Macro way: Select your cells then run the attached code

sub AddLetters
dim cl as range
for each cl in selection.cells
    cl="#"&cl.value
next cl
end sub

Open in new window


Thomas
0
 
jss1199Commented:
Using macro...
1. Select the range that you want to insert the prefix or suffix.
2. Click Developer > Visual Basic, click Insert > Module, and then input the following code:
Sub AddPrefix()
'Updateby20131204
Dim Rng As Range
Dim WorkRng As Range
Dim addStr As String
On Error Resume Next
xTitleId = "AddPrefixToCellRange"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
addStr = Application.InputBox("Add text", xTitleId, "", Type:=2)
For Each Rng In WorkRng
    Rng.Value = addStr & Rng.Value
Next
End Sub

Open in new window

3. Run the macro AddPrefix and enter the range that you want to insert the prefix and then enter the character(s) to add - this can be used for your current situation and others that may require different prefixes without modifying the macro
0
 
andrew_manCommented:
No need VBA

Just type

="#"&A1

then, copy and paste value
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
jss1199Commented:
agreed, andrew but the OP did not want to touch each row...
0
 
regmigrantCommented:
All of the above will work but if this is a one off and the 'data' part is common you can just use find/replace - find 'data', replace with '#data'

Reg
0
 
Rob HensonFinance AnalystCommented:
OP won't have to touch each row but will only need to insert formula in first row and then fill down, using either Ctrl + D or double click the fill handle.

Then copy paste special.
0
All Courses

From novice to tech pro — start learning today.