Home » excel » excel – Lookup by Range

excel – Lookup by Range

Posted by: admin May 14, 2020 Leave a comment


I have the following table:

enter image description here

I need to fill the Group column with A, B, … using the age of the person and matching to Age Ranges.

So John, with age 5, would get the Group A. I was looking at the VLookup and HLookup functions.

The problem is that I am not sure if this is possible because of the Age Ranges: 0-7, 8-14, etc.

Do I need VBA for this?

How to&Answers:

Yes, VLOOKUP is the way to go,and there is no need for VBA. Here’s the setup:

.enter image description here

Couple of things to notice.

  • The break points for the lookup are the lower bound of each group range

  • the lookup range itself is sorted

  • the third argument of the lookup is TRUE (the default) which means the function does a range rather than an exact lookup.


I prefer @chuff’s answer but since this is SO you could use code such as:-

Sub Macro1()
ActiveCell.FormulaR1C1 = _
Range(ActiveCell, ActiveCell.End(xlDown)).Offset(0, 1).Select
End Sub  

assuming you want A for John in C2.