#1   Report Post  
Posted to microsoft.public.excel.misc
Pat Pat is offline
external usenet poster
 
Posts: 210
Default Trimming Data

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!U210000,Mill enia!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!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 461
Default Trimming Data

You can try and use the Left function

=IF(Millenia!U2="",99999,IF(Millenia!U210000,Mill enia!U2,LEFT(Millenia!U2,5))

"Pat" wrote:

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!U210000,Mill enia!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!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 857
Default Trimming Data

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.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"Pat" wrote:

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!U210000,Mill enia!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!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
TRIM not trimming Kim Excel Worksheet Functions 7 August 10th 07 12:48 AM
TRIM not trimming Kim Excel Worksheet Functions 0 August 8th 07 11:22 PM
Trimming text scott Excel Worksheet Functions 4 December 16th 06 04:49 PM
Trimming Data Terry Bennett Excel Worksheet Functions 4 July 17th 06 02:57 PM
IP Trimming Josh Excel Discussion (Misc queries) 1 June 16th 06 04:34 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"