Looking up values

  • Thread starter Thread starter Nathan Carroll
  • Start date Start date
N

Nathan Carroll

The following two function work for looking up a value but if I make a
change to the Row/Column that contains the lookup value my lookup value does
not change. I have my sheet on automatic calculate. Should these function
types be ranges?


Function VLook(lookupValue As Range, LookupRange As Range, Column As
Integer) As Double
Dim cell As Range
For Each cell In LookupRange
If cell = lookupValue Then
VLook = cell.Offset(0, Column - 1)
End If
Next cell
End Function

Function HLook(lookupValue As Range, LookupRange As Range, Row As Integer)
As Double
Dim cell As Range
For Each cell In LookupRange
If cell = lookupValue Then
HLook = cell.Offset(Row - 1, 0)
Exit Function
End If
Next cell
End Function
 
I find vlookup and hlookup to finicky.


Don Guillett said:
Maybe you need to add application.volatile but

Why are you re-inventing the wheel?
 

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