Hlookup, but to next highest value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I'm using vba to enter the following code into some cells programatically:
Range(strHlookupCell).Value = "=HLOOKUP(A3,TCtl_DateRange,1,TRUE)".
where strHlookupCell = Sheet "PData" Range N3;
and TCtl_DataRange = Sheets "Control" Range B5:BA5

TCtl_DataRange is a listing of dates incrementing by 1 week.
What i need to be able to do, is look at cell A3 which is a date, and lookup
the TCtl_DataRange and find the next highest match. Not all values in A3 will
match perfectly to a value in TClt_DataRange.

Is there a way to lookup the value in A3 and return either an exact match,
or return the next highest value?

The code im using returns the closest value, not the next highest value.

Thanks.

Tones.
 
Tony
To find a match of A3 or next highest value:

=INDEX(TctL_dateRange,MATCH(A3,TctL_dateRange)+NOT(INDEX(TctL_dateRange,MATCH(F1,TctL_dateRange))=A3))

Don Pistulka
 
Thank you heaps Don.
It works great.
I had no idea about the index function.

Cheers.
Tones.
 
My Bad

I meant to change the F1 to A3, like this:

=INDEX(TctL_dateRange,MATCH(A3,TctL_dateRange)+NOT(INDEX(TctL_dateRange,MATCH(A3,TctL_dateRange))=A3))

Don Pistulka
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top