|
-
Feb 18th, 2006, 04:42 AM
#1
Thread Starter
Member
[RESOLVED] Run-time Error 424 "Object needed" is bugging me
Following Function give Run-time Error 424 Object needed in the line:LookupValue = Application.Caller.Offset(0, -1).Value.
Where do I use a wrong data type?
Formula gives back only "0", nomather if the statement is true or false.
VB Code:
Function LookOneBack() As Long
Dim LookupValue As Variant
Dim rngMatrix As Range
Application.Volatile
LookupValue = Application.Caller.Offset(0, -1).Value
Set rngMatrix = ThisWorkbook.Worksheets(1).Range("B1:B4")
If rngMatrix.Find(What:=LookupValue, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False) Is Nothing Then
LookOneBack = 0
Else
LookOneBack = 2
End If
Set rngMatrix = Nothing
End Function
Last edited by Tobian; Feb 21st, 2006 at 06:31 AM.
-
Feb 18th, 2006, 08:56 AM
#2
Thread Starter
Member
Re: Run-time Error 424 Object needed
I simplified the function and now it works . Still, when I debug the function it gives same Run-time Error 424 Object needed. Can anyone solve this bug for me?
VB Code:
Function LookOneBack() As Variant
Application.Volatile
LookOneBack = Application.Caller.Offset(0, -1).Value
End Function
Last edited by Tobian; Feb 18th, 2006 at 09:06 AM.
-
Feb 20th, 2006, 11:19 AM
#3
Thread Starter
Member
Re: Run-time Error 424 "Object needed" is bugging me
Oke solved the bug.
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|