Trimming Data

P

Pat

I am attempting to manipulate data that is imported in an Excel spreadsheet.
Some fields contain a zip code, some contain zip code + 4 and some don't
contain any zip code. I have to export the data to a system that requires a
standard 5 digit zip code only (for all data). I have used the following
formula to correct data rows that have no zip code, but I'm not sure how to
get rid of the +4 if they are present. I tried using trim and mid without
much luck. Likely I'm just not getting the formula correct.

Here's the current formula
=IF(Millenia!U2="",99999,IF(Millenia!U2>10000,Millenia!U2,CONCATENATE(Millenia!U2,1)))

This fixes the issue of no zip code or a zip code with one missing number
(not best fix but it works to get data uploaded). The question is, how can I
modify this formula to trip the +4 when and if present?

Thanks in advance for your help!
 
A

akphidelt

You can try and use the Left function

=IF(Millenia!U2="",99999,IF(Millenia!U2>10000,Millenia!U2,LEFT(Millenia!U2,5))
 
S

Shane Devenshire

Hi,

Unless I misinterpret your question, you will find this solution works for you

=IF(A1="","99999",RIGHT("0000"&LEFT(A1,5),5))

Replace the references to A1 with your Millenia!U2 ones. Also, depending on
details you may be able to remove the quotes around 99999.
 

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