Cell lookup - based on range and two other cells

dblue42

New Member
Joined
Feb 3, 2022
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hello,

Newbie here. I am trying to automate the processing of survey data, to make life quicker and easier. The surveying trolley takes measurements at regular intervals, and logs these alongside the distance travelled (either KM/Metres or Miles/Yards). Some of the locations along the route have a site name, with a known distance limits (e.g. Site 1 is from 30.980km to 30.990km).

1644836756745.png
1644836866574.png


What I want is either a formula or a script that fills in the location names automatically, so for example cells C2:C3 both have "Site 1" filled in for me.

I have found a similar example of this on the forum, but can't get my head around the code to make this work for me. Can anyone help please?

Thanks.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
so for example cells C2:C3 both have "Site 1" filled in for me.
.. and what would C4 have, given that 31.0 does not come in any of the ranges in the lookup table?
Similar for C7 & C8?
 
Upvote 0
.. and what would C4 have, given that 31.0 does not come in any of the ranges in the lookup table?
Similar for C7 & C8?
Good question. Not all locations have names; so C4 would normally be left blank.

This may seem a bit odd, but its the nature of the infrastructure I'm working with.
 
Upvote 0
For the future, this would likely get you more response as helpers would not have to manually type out the sample data to test with. ;)
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.

See if this could work for you.

22 02 14.xlsm
ABCDEFGHI
1
230980.5Site 1
330990Site 1Site 13098030990
4310 Site 2311031115
531110Site 2Site 33122031250
631115Site 2
731120 
831200 
931220.5Site 3
1031230Site 3
Lookup
Cell Formulas
RangeFormula
C2:C10C2=IF(SUMPRODUCT(--(A2>=F$3:F$5),--(B2>=G$3:G$5),--(A2<=H$3:H$5),--(B2<=I$3:I$5))=0,"",INDEX(E$3:E$5,SUMPRODUCT(--(A2>=F$3:F$5),--(B2>=G$3:G$5),--(A2<=H$3:H$5),--(B2<=I$3:I$5),ROW(E$3:E$5)-ROW(E$3)+1)))
 
Upvote 0
Solution
Thanks Peter, that has worked perfectly. I'll remember your advice about posting rules for next time.
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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