#1   Report Post  
Posted to microsoft.public.excel.misc
CM CM is offline
external usenet poster
 
Posts: 136
Default look up zip code

I'm trying to deal with 3 digit zip codes. I'm trying to associate prices
with these zip codes, but when I convert a 5 digit zip to 3 digits, I can't
use the result in any vlookup or if satments.

For instance, I convert a zip from 5 to 3 digits using the LEFT function:

=LEFT(A1,3)

Then I try to use the result to determine which range of 3 digit zips the
original zip falls into. So if I want to find out if the first 3 digits fall
in the range 606-612, I tried using this:

=IF(AND(LEFT(A1,3)=606,LEFT(A1,3)<=612),1,0)

But it doesn't return a valid response if those 3 digits fall into that
range of 606-612. Any guidance is appreciated. Thanks!
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default look up zip code

The left function returns text but you are comparing that to a number... Add
some quotation marks...

=IF(AND(LEFT(A1,3)="606",LEFT(A1,3)<="612"),1,0)
or just
=AND(LEFT(A1,3)="606",LEFT(A1,3)<="612")
which will return true or false as the case warrants.

--
HTH...

Jim Thomlinson


"CM" wrote:

I'm trying to deal with 3 digit zip codes. I'm trying to associate prices
with these zip codes, but when I convert a 5 digit zip to 3 digits, I can't
use the result in any vlookup or if satments.

For instance, I convert a zip from 5 to 3 digits using the LEFT function:

=LEFT(A1,3)

Then I try to use the result to determine which range of 3 digit zips the
original zip falls into. So if I want to find out if the first 3 digits fall
in the range 606-612, I tried using this:

=IF(AND(LEFT(A1,3)=606,LEFT(A1,3)<=612),1,0)

But it doesn't return a valid response if those 3 digits fall into that
range of 606-612. Any guidance is appreciated. Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,856
Default look up zip code

LEFT will return a text result, so try it this way:

=IF(AND(LEFT(A1,3)*1=606,LEFT(A1,3)*1<=612),1,0)

Hope this helps.

Pete


"CM" wrote in message
...
I'm trying to deal with 3 digit zip codes. I'm trying to associate prices
with these zip codes, but when I convert a 5 digit zip to 3 digits, I
can't
use the result in any vlookup or if satments.

For instance, I convert a zip from 5 to 3 digits using the LEFT function:

=LEFT(A1,3)

Then I try to use the result to determine which range of 3 digit zips the
original zip falls into. So if I want to find out if the first 3 digits
fall
in the range 606-612, I tried using this:

=IF(AND(LEFT(A1,3)=606,LEFT(A1,3)<=612),1,0)

But it doesn't return a valid response if those 3 digits fall into that
range of 606-612. Any guidance is appreciated. Thanks!



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,651
Default look up zip code

You've got confused between text and numbers.
Try =IF(AND(--LEFT(A1,3)=606,--LEFT(A1,3)<=612),1,0)
--
David Biddulph

"CM" wrote in message
...
I'm trying to deal with 3 digit zip codes. I'm trying to associate prices
with these zip codes, but when I convert a 5 digit zip to 3 digits, I
can't
use the result in any vlookup or if satments.

For instance, I convert a zip from 5 to 3 digits using the LEFT function:

=LEFT(A1,3)

Then I try to use the result to determine which range of 3 digit zips the
original zip falls into. So if I want to find out if the first 3 digits
fall
in the range 606-612, I tried using this:

=IF(AND(LEFT(A1,3)=606,LEFT(A1,3)<=612),1,0)

But it doesn't return a valid response if those 3 digits fall into that
range of 606-612. Any guidance is appreciated. Thanks!





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
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Code to find code D. Excel Discussion (Misc queries) 2 August 12th 07 06:16 PM
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
Unprotect Code Module in Code Damien Excel Discussion (Misc queries) 2 April 18th 06 03:10 PM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM


All times are GMT +1. The time now is 05:14 PM.

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

About Us

"It's about Microsoft Excel"