Appending to fields

A

Amon Borland

I have a 400 row column called zipcode. Obviously, it contains 400
different zipcodes. For each record, I need to append or concatenate some
punctuation to it.

Zipcodes look like this 12345, I want each one to look like '12345',

That is, adding paranthesis around the number, and a comma after each
number.

Any easy way to do this?

Thanks for the help!
 
M

Mike Fogleman

Sub AlterZip()
Dim c As Range
Dim zip As Range
Dim a As String 'leading puctuation
Dim b As String ' trailing puctuation
Dim x As String ' current zip value

Set zip = Worksheets("Sheet1").Range("A1:A400") 'change to fit your location
a = "''"
b = "',"

For Each c In zip
x = c.Value
c.Value = a + x + b
Next c
End Sub

Note: a = "''" is two apostrophes enlosed in quotes.[" ' ' "]
The first apostophe will make the cell text and will not be displayed.

Mike F
 

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

Top