When I insert following Public Function ValueOneBack() in a Cell of a Excel worksheet, it works.
Eg. when I insert ValueOneBack() in Cell H7, it returns the value of Cell G8.
Now I want to know if the result of ValueOneBack() is also present in Range B1:B4. So I use the result of ValueOneBack() as LookupValue in the Function MatchOneBack(). But now ValueOneBack() doesn't return a value, which makes MatchOneBack() always false.
Can somebody tell me what I do wrong?
VB Code:
Public Function ValueOneBack() As Variant ValueOneBack = "" Application.Volatile If TypeName(Application.Caller) = "Range" Then If Application.Caller.Row <> 65536 And Application.Caller.Column <> 1 Then ValueOneBack = Application.Caller.Offset(1, -1).Value End If End If End Function Function MatchOneBack() As Integer Dim LookupValue As Variant Dim rngMatrix As Range LookupValue = ValueOneBack Set rngMatrix = Worksheets(1).Range("B1:B4") If rngMatrix.Find(What:=LookupValue, _ LookIn:=xlValues, _ LookAt:=xlWhole, _ MatchCase:=False) Is Nothing Then MatchOneBack = 0 Else MatchOneBack = 2 End If Set rngMatrix = Nothing End Function




Reply With Quote