Link to home
Start Free TrialLog in
Avatar of IT-NYC
IT-NYC

asked on

Preserve ZipCode and Zip4 formatting while saving as .csv

I need to preserve ZipCode and Zip4 formatting in .cvs. No matter what I do (have been through a few suggestions through Google), it truncates 0s after saving as .csv
Avatar of IT-NYC
IT-NYC

ASKER

The original data is in Excel 2010.
SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
My postcode is 'GU3 2EB', and I don't have any problem with it :)
Yes, Graham, but you all drive on the wrong side of the road.  It's a wonder anyone makes it home alive :)
I'm OK in Japan,  but there are greater hazards there.
I agree with the brain trust above. Postal Codes should use a text field.

However... if it's necessary to store it in a number field you could always add the leading zeros to the string when you want to display it on a form or report using a function.


'Example:

Public Function AddLeadingZeros(PostalCode As String) As String
Dim ReturnedString As String
Dim NumOfZerosToAdd As Integer

  NumOfZerosToAdd = 5 - Len(PostalCode)
  ReturnedString = String(NumOfZerosToAdd, "0") & PostalCode
  AddLeadingZeros = ReturnedString

End Function

Open in new window

Avatar of IT-NYC

ASKER

I am enjoying this conversation:) It started so innocent :)
My .cvs file has to be used in the Microsoft CRM 4.0 import function, so it needs to be stored properly within the file itself. I tried all the suggestions, even prior to the post. It actually does display the 0s properly when opened in Notepad but when used in the CRM import, it brings '876' instead of '00876'.
I am attaching a sample for your review
zip.csv
This is the way I think it should be formatted as all text.
zip2.csv
Avatar of IT-NYC

ASKER

Thank you everyone!
I believe the key issue was not to open the properly formatted file in Excel again. Check in Notepad to make sure it is correctly formatted and use it.
I did that and my import to CRM process worked correctly.