?
Solved

Excel prepend character

Posted on 2013-12-04
6
Medium Priority
?
326 Views
Last Modified: 2013-12-04
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
0
Comment
Question by:techdrive
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 2000 total points
ID: 39695987
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
 
LVL 19

Expert Comment

by:jss1199
ID: 39696014
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
 
LVL 4

Expert Comment

by:andrew_man
ID: 39696017
No need VBA

Just type

="#"&A1

then, copy and paste value
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:jss1199
ID: 39696043
agreed, andrew but the OP did not want to touch each row...
0
 
LVL 19

Expert Comment

by:regmigrant
ID: 39696045
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
 
LVL 33

Expert Comment

by:Rob Henson
ID: 39696167
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question