ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   multidimensional lookup? (https://www.excelbanter.com/excel-programming/276679-multidimensional-lookup.html)

Lightspeed

multidimensional lookup?
 
I would like to know if it is possible to return a value
by specifying how far away (in rows and columns) the
result is from the lookup_value. For example, I would
like to look up today's date from a column list, and then
return the value that is one column over and 2 rows down.
Please let me know if this is even possible.

J.E. McGimpsey

multidimensional lookup?
 
One way:

Dim result As Variant
Dim lookup_Value As Variant
lookup_Value = Range("C1").Value
result = Columns(1).Cells.Find( _
What:=lookup_Value, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False).Offset(2, 1).Value
MsgBox result


If it's not guaranteed that the lookup_value will be found, you can
use something like:

Dim found As Range
Dim result As Variant
Dim lookup_Value As Variant
lookup_Value = Range("C1").Value
Set found = Columns(1).Cells.Find( _
What:=lookup_Value, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False)
If Not found Is Nothing Then result = found.Offset(2, 1).Value
MsgBox result



In article ,
"Lightspeed" wrote:

I would like to know if it is possible to return a value
by specifying how far away (in rows and columns) the
result is from the lookup_value. For example, I would
like to look up today's date from a column list, and then
return the value that is one column over and 2 rows down.
Please let me know if this is even possible.



All times are GMT +1. The time now is 06:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com