0

I have a excel file with a zip codes and I need get the first 2 numbers =LEFT(G2;2);

for this postal codes like 11008 it works, I get 11, but if a postal code has as value 01008 this doesn't works because the unformatted (Real Value) value is 1008

Any ideas?

Pedro Monteiro
  • 336
  • 2
  • 16

2 Answers2

6

You could turn the zip code first into text using TEXT:

=LEFT(TEXT(G2;"00000");2)

1008 becomes 01008 first, and then you get 01 from the LEFT function.

Jerry
  • 70,495
  • 13
  • 100
  • 144
2

Your ZIP code column should really be formatted as Text. Even though the ZIP code happens to be represented with numerals, it's not really a number per se.

  • You don't do math with it;
  • it could just as easily be represented with letters (and is in some countries);
  • leading zeros are important.

Same thing with, say, phone numbers.

Here's some relevant questions:

Community
  • 1
  • 1
Charles Wood
  • 864
  • 8
  • 23