ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Appending to fields (https://www.excelbanter.com/excel-programming/347152-appending-fields.html)

Amon Borland

Appending to fields
 
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!



Mike Fogleman

Appending to fields
 
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
"Amon Borland" wrote in message
...
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!





All times are GMT +1. The time now is 09:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com