Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Is there a better way?

The only way I know how to do this is with a really ugly nested IF
statement. Is there a better way?

I have 8 "zones" of numbers and I need to determine which zone this
number fits into.

zn1 zn2 zn3
zn4 zn5 zn6 zn7
zn8
1410 1416 1416 1421 1421 1423 1423 1436 1436 1437 1437
1439 1439 1445 1445 1450

If I need to know what zone number 1422 fits into I can only to think
of a nested IF statement:

IF(P2G2,IF(P2<H2,"ZN3").......................... .................................................. ......................................)

I am thinking there must be an easier more efficient way. Any ideas?
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Is there a better way?

On Nov 2, 7:30*am, Ymtrader wrote:
The only way I know how to do this is with a really ugly nested IF
statement. *Is there a better way?

I have 8 "zones" of numbers and I need to determine which zone this
number fits into.

* * * zn1 * * * * * * * zn2 * * * * * * * * zn3
zn4 * * * * * zn5 * * * * * * *zn6 * * * * *zn7
zn8
1410 *1416 * * * 1416 *1421 * *1421 1423 *1423 1436 *1436 1437 *1437
1439 *1439 1445 *1445 1450

If I need to know what zone number 1422 fits into I can only to think
of a nested IF statement:

IF(P2G2,IF(P2<H2,"ZN3").......................... ..........................*....................... ........................................)

I am thinking there must be an easier more efficient way. *Any ideas?
Thanks!


Har zn1 zn2 zn3
zn4 zn5 zn6 zn7
zn8
1410 1416 1416 1421 1421 1423 1423 1436 1436 1437 1437
1439 1439 1445 1445 1450

Hard to tell from your broken paste
"If desired, send your file to dguillett @gmail.com I will only look
if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results."
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default Is there a better way?

On 02/11/2010 12:56, Don Guillett Excel MVP wrote:
On Nov 2, 7:30 am, wrote:
The only way I know how to do this is with a really ugly nested IF
statement. Is there a better way?

I have 8 "zones" of numbers and I need to determine which zone this
number fits into.

zn1 zn2 zn3
zn4 zn5 zn6 zn7
zn8
1410 1416 1416 1421 1421 1423 1423 1436 1436 1437 1437
1439 1439 1445 1445 1450

If I need to know what zone number 1422 fits into I can only to think
of a nested IF statement:

IF(P2G2,IF(P2<H2,"ZN3").......................... .........................*........................ .......................................)

I am thinking there must be an easier more efficient way. Any ideas?


It looks like what you want is some variant of HLOOKUP - minor syntax
restriction is that it requires the lookup to be on the first row and
for a nearest match to work the first line must be in ascending order.

G: 1 4 10 20
H: zn1 zn2 zn3 zn4

Assuming it starts in rows G, H from column1 then

=HLOOKUP(P2, $G$1..$H$8,2,1)

ought to do what you want.

Regards,
Martin Brown
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,856
Default Is there a better way?

Your numbers seem to define a range, although you only need the lower
number of each range, like this:

zn1 zn2 zn3 zn4 zn5 zn6 zn7 zn8
1410 1416 1421 1423 1436 1437 1439 1445

Assume these occupy the top two rows of your sheet, beginning in A1,
and that the number to be tested is in A4. You can put this formula in
B4:

=IF(A4<A2,"too small",IF(A41450,"too
large",INDEX(A1:H1,MATCH(A4,A2:H2))))

This will return the zone number as long as A4 is in range, and will
give error messages if it is not.

Hope this helps.

Pete

On Nov 2, 12:30*pm, Ymtrader wrote:
The only way I know how to do this is with a really ugly nested IF
statement. *Is there a better way?

I have 8 "zones" of numbers and I need to determine which zone this
number fits into.

* * * zn1 * * * * * * * zn2 * * * * * * * * zn3
zn4 * * * * * zn5 * * * * * * *zn6 * * * * *zn7
zn8
1410 *1416 * * * 1416 *1421 * *1421 1423 *1423 1436 *1436 1437 *1437
1439 *1439 1445 *1445 1450

If I need to know what zone number 1422 fits into I can only to think
of a nested IF statement:

IF(P2G2,IF(P2<H2,"ZN3").......................... ..........................*....................... ........................................)

I am thinking there must be an easier more efficient way. *Any ideas?
Thanks!


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Is there a better way?

Two questions...

1. Are the two values making up a single zone in the same cell or in two
different cells?

2. You need to tell us what is supposed to happen with numbers like 1416
which fall on the boundary of two adjacent zones (that is, which zone does
it belong to)?

It would help us if you told us the columns making up each zone so we can
see how to address your numbers.

--
Rick Rothstein (MVP - Excel)


"Ymtrader" wrote in message
...
The only way I know how to do this is with a really ugly nested IF
statement. Is there a better way?

I have 8 "zones" of numbers and I need to determine which zone this
number fits into.

zn1 zn2 zn3
zn4 zn5 zn6 zn7
zn8
1410 1416 1416 1421 1421 1423 1423 1436 1436 1437 1437
1439 1439 1445 1445 1450

If I need to know what zone number 1422 fits into I can only to think
of a nested IF statement:

IF(P2G2,IF(P2<H2,"ZN3").......................... .................................................. ......................................)

I am thinking there must be an easier more efficient way. Any ideas?
Thanks!




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Is there a better way?

On Nov 2, 8:19*am, "Rick Rothstein"
wrote:
Two questions...

1. Are the two values making up a single zone in the same cell or in two
different cells?

2. You need to tell us what is supposed to happen with numbers like 1416
which fall on the boundary of two adjacent zones (that is, which zone does
it belong to)?

It would help us if you told us the columns making up each zone so we can
see how to address your numbers.

--
Rick Rothstein (MVP - Excel)

"Ymtrader" wrote in message

...

The only way I know how to do this is with a really ugly nested IF
statement. *Is there a better way?


I have 8 "zones" of numbers and I need to determine which zone this
number fits into.


* * *zn1 * * * * * * * zn2 * * * * * * * * zn3
zn4 * * * * * zn5 * * * * * * *zn6 * * * * *zn7
zn8
1410 *1416 * * * 1416 *1421 * *1421 1423 *1423 1436 *1436 1437 *1437
1439 *1439 1445 *1445 1450


If I need to know what zone number 1422 fits into I can only to think
of a nested IF statement:


IF(P2G2,IF(P2<H2,"ZN3").......................... .................................................. .......................................)


I am thinking there must be an easier more efficient way. *Any ideas?
Thanks!


Rick, thank you I see now that this was not clear. The numbers on the
sheet are not as I posted. I posted as a way to explain but in turn
gave the wrong information for the needed solution, the layout is as
such: Each number is in it's own cell

a1:1410 b1:1416 c1:1421 d1:1423 e1:1436 f1:1437 g1:1439 h1:1445
i1:1450 - So a number that falls between the 2 adjecent numbers will
define the zone. ie a number of 1415 would be in zone 1 a number of
1448 would be in zone 8. Zone 1 would be greater or equal to 1410
but less than 1416 Zone 2 would be greater or equal to 1416 but less
than 1421 ect. Sorry for the miss communication.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,059
Default Is there a better way?

On Nov 2, 7:47*am, Ymtrader wrote:
a1:1410 b1:1416 c1:1421 d1:1423 e1:1436 f1:1437 g1:1439 h1:1445
i1:1450 - *So a number that falls between the 2 adjecent numbers will
define the zone. *ie a number of 1415 would be in zone 1 a number of
1448 would be in zone 8. * Zone 1 would be greater or equal to 1410
but less than 1416 * Zone 2 would be greater or equal to 1416 but less
than 1421 ect.


=MATCH(A2,A1:I1)

gives the zone number. If you want text:

="ZN" & MATCH(A2:A1:I1)


PS: For broader participation, you might want to post future
inquiries using the MS Answers Forums at
http://social.answers.microsoft.com/...ry/officeexcel.
It's not that I like that forum. It's just that MS has ceased to
support the Usenet newsgroups. Hence, participation here is limited
to the sites that share a common newsgroup mirror, which is no longer
centralized at MS.
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Is there a better way?

On Nov 2, 10:18*am, joeu2004 wrote:
On Nov 2, 7:47*am, Ymtrader wrote:

a1:1410 b1:1416 c1:1421 d1:1423 e1:1436 f1:1437 g1:1439 h1:1445
i1:1450 - *So a number that falls between the 2 adjecent numbers will
define the zone. *ie a number of 1415 would be in zone 1 a number of
1448 would be in zone 8. * Zone 1 would be greater or equal to 1410
but less than 1416 * Zone 2 would be greater or equal to 1416 but less
than 1421 ect.


=MATCH(A2,A1:I1)

gives the zone number. *If you want text:

="ZN" & MATCH(A2:A1:I1)

PS: *For broader participation, you might want to post future
inquiries using the MS Answers Forums athttp://social.answers.microsoft.com/Forums/en-US/category/officeexcel.
It's not that I like that forum. *It's just that MS has ceased to
support the Usenet newsgroups. *Hence, participation here is limited
to the sites that share a common newsgroup mirror, which is no longer
centralized at MS.


Thank you all for your help, I will try each of the suggestions.
Again thank you!
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



All times are GMT +1. The time now is 09:45 PM.

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"