View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default How do I find a dash in a cell with numbers in it in excel.

On Thu, 13 Aug 2009 13:31:02 -0700, Finky
wrote:

I'm working in Excel 2003 with zip codes, people supply them in 5 digit, 9
digit or 9 digit with dash. I used
=IF(FIND("-",(A14))0,LEFT(A14,FIND("-",(A14))-1),A14) to get the 5 digit but
if there is no dash it will value out. Does anyone know how I can test the
cell for the dash first.


It looks like you are trying to obtain the first five digits of zip codes,
entered in various formats. Try this which should retain leading zeros:

=LEFT(TEXT(SUBSTITUTE(A1,"-",""),"[<100000]00000;00000-0000"),5)

Of course, this does not test to ensure your data is in one of the three
acceptable formats.

--ron