[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Excel prepend character

Posted on 2013-12-04
6
Medium Priority
?
338 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
Industry Leaders: 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

Industry Leaders: 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!

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
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 …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

649 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