Paste/add text to beginning of multiple fields in Excel

  • Thread starter Thread starter stonelinton
  • Start date Start date
S

stonelinton

I have a table setup already, but realized that on field requires I add
'CEP' to the beginning of the values in 1444 fields (same column). I
don't want to go through field by field and paste, is there a way to
merge values or join fields . . . etc?
 
Assuming your numeric data is in A2:A1445, put this formula in any empty
column in row 2:

="CEP" & A2

Then copy down; next, copy this new column and paste special > values
over the original data in A2:A1445. Finally, delete the temporary column
and you're done.

HTH,
Nikos
 
For numbers in column A, this macro will do it.....

Sub ConcatenateMe()
Dim lastrow As Long, r As Long
Dim cv As String
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For r = lastrow To 1 Step -1
If Cells(r, "A") <> "" Then
Cells(r, "A").Select
cv = Selection.Value
End If
With ActiveCell
.Value = "CEP" & cv
End With
Next r
End Sub

Vaya con Dios,
Chuck, CABGx3
 
This worked . . . once. I had to add ( ) around formula, but it won't
work again. It just shows up as text in the field. Any suggestions?
Thanks.
 
...It just shows up as text in the field.
Probably because the cells were already formatted as Text! Change the
cell formatting to General and hit F9 to recalculate. The brackets
shouldn't be required.

HTH,
Nikos
 
Works perfectly. Thanks Nikos. Probably saved me half a days work.
 

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

Back
Top