jjcrazy

New Member
Joined
Nov 18, 2014
Messages
11
I have a list of locations, with their coordinates, and I have a set of regions of which I have the coordinates of the border points. Now I would like excel to specify for me in what region every location is.

I was thinking of using a nested IF function, but I have up to 20 regions so I am hoping there may be an easier way to do this.

For example:

ABCDEF
1locationNE
2location 151,20885,995877
3
4nametopleftbottomright
5region 151,0683525,66177550,7457506,054801
6region 251,5615385,82307051,0683525,661775
7region 351,5615385,20185451,0683525,823070

<colgroup><col><col><col span="4"></colgroup><tbody>
</tbody>


So if C2 falls between C5 and E5, AND D2 falls between D5 and F5, I want it to tell me region 1.
Else if C2 falls between C6 and E6, AND D2 falls between D6 and F6, I want it to tell me region 2, etc.

Is there any function that can do this more easily?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
try this

copy G5 down to all regions


Excel 2012
ABCDEFG
1locationNE
2location 151.2088005.995877region 4
3
4nametopleftbottomright
5region 151.0683525.66177550.7457506.054801FALSE
6region 251.5615385.82307051.0683525.661775FALSE
7region 351.5615385.20185451.0683525.823070FALSE
8region 451.3615385.20185451.0683526.823070TRUE
Sheet1
Cell Formulas
RangeFormula
F2=INDEX(B:B,MATCH(TRUE,G:G,0))
G5=AND($C$2>=MIN(C5,E5),$C$2<=MAX(C5,E5),$D$2>=MIN(D5,F5),$D$2<=MAX(D5,F5))
 
Upvote 0
Thanks so much!
The only thing is, I have over a thousand locations that I want to do this for. This will only work for one at a time right?
 
Upvote 0
yes, this solution is not good for a long list of co-ordinates, let me have another think about it
 
Upvote 0
Try this array formula.
Confirm with Ctrl+Shift+Enter

=INDEX(B5:B8,MATCH(1,(C2<=$C$5:$C$8)*(C2>=$E$5:$E$8)*(D2>=$D$5:$D$8)*(D2<=$F$5:$F$8),0))
 
Upvote 0
Try this array formula.
Confirm with Ctrl+Shift+Enter

=INDEX(B5:B8,MATCH(1,(C2<=$C$5:$C$8)*(C2>=$E$5:$E$8)*(D2>=$D$5:$D$8)*(D2<=$F$5:$F$8),0))

problem when the co-ords are the other way round, e.g.

name top left bottom right
region 1 51.068352 5.661775 50.74575 6.054801
region 2 51.561538 5.82307 51.068352 5.661775
region 3 51.561538 5.201854 51.068352 5.82307
region 4 51.068352 5.201854 51.361538 6.82307

location 1 51.208800 5.995877 should still in region 4.
 
Upvote 0
You cant list the coordinates in the region table consistently so that one side is always larger than its oppisite?
 
Last edited:
Upvote 0
You cant list the coordinates in the region table consistently so that one side is always larger than its oppisite?

Yes I guess I can make the regions in a way that they don't overlap. If they are exclusive than this must work!

Thanks!
 
Upvote 0
Try this array formula.
Confirm with Ctrl+Shift+Enter

=INDEX(B5:B8,MATCH(1,(C2<=$C$5:$C$8)*(C2>=$E$5:$E$8)*(D2>=$D$5:$D$8)*(D2<=$F$5:$F$8),0))

Ok so I tried it with this table and the values below:

Regionbottomtopleftright
region 15151,43,43,67
region 25151,343,673,9
region 35151,353,94,36
region 451,3551,74,14,35
region 551,3551,73,84,1
region 651,3551,73,43,8
region 751,751,83,43,8
region 851,3551,714,354,65
loc a51,326983,489644#VALUE!

<tbody>
</tbody>

And it returned #value..

I typed the following formula:
=INDEX($A$1:$A$9;MATCH(1;(B12<=$C$1:$C$9)*(B12>=$B$1:$B$9)*(C12>=$D$1:$D$9)*(C12<=$E$1:$E$9);0))

What did I do wrong?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,428
Messages
6,124,832
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top