ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Zip codes in mail merges (https://www.excelbanter.com/excel-programming/293561-re-zip-codes-mail-merges.html)

Tom Ogilvy

Zip codes in mail merges
 
for each cell in Range(Cells(1,"D"),Cells(rows.count,"D").End(xlup) )
if len(cell.value) = 9 then
cell.value = "'" & left(cell.value,5) & "-" & Right(Cell.value,4)
end if
Next

Untested

would be code to convert them. I can't say if there is built in support for
it.

--
Regards,
Tom Ogilvy

"Brucek" wrote in message
...
I have fomatted a column containing bot 5 and 9 digit zip codes. However

when I mailmerge these into a word document the "-" is missing in the 9
digit zip codes. When I click on a cell the number is actually a 9 digit
number with no "-".

How can I convert the numbers to text keeping the "-" or how do I mail

merge keeping the proper zip code format.



david mcritchie

Zip codes in mail merges
 
If that doesn't work try cell.text on the right side, which
will take what you see. Format the column as text
ahead of time.

Better test these on a copy of the worksheet.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Tom Ogilvy" wrote in message ...
for each cell in Range(Cells(1,"D"),Cells(rows.count,"D").End(xlup) )
if len(cell.value) = 9 then
cell.value = "'" & left(cell.value,5) & "-" & Right(Cell.value,4)
end if
Next

Untested

would be code to convert them. I can't say if there is built in support for
it.

--
Regards,
Tom Ogilvy

"Brucek" wrote in message
...
I have fomatted a column containing bot 5 and 9 digit zip codes. However

when I mailmerge these into a word document the "-" is missing in the 9
digit zip codes. When I click on a cell the number is actually a 9 digit
number with no "-".

How can I convert the numbers to text keeping the "-" or how do I mail

merge keeping the proper zip code format.







All times are GMT +1. The time now is 01:07 AM.

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