Results 1 to 3 of 3

Thread: [RESOLVED] Run-time Error 424 "Object needed" is bugging me

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Location
    Holland
    Posts
    34

    Resolved [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:
    1. Function LookOneBack() As Long
    2. Dim LookupValue As Variant
    3. Dim rngMatrix As Range
    4.  
    5.         Application.Volatile
    6.        
    7.         LookupValue = Application.Caller.Offset(0, -1).Value
    8.         Set rngMatrix = ThisWorkbook.Worksheets(1).Range("B1:B4")
    9.        
    10.         If rngMatrix.Find(What:=LookupValue, _
    11.                             LookIn:=xlValues, _
    12.                             LookAt:=xlWhole, _
    13.                             MatchCase:=False) Is Nothing Then
    14.             LookOneBack = 0
    15.         Else
    16.             LookOneBack = 2
    17.         End If
    18.        
    19.         Set rngMatrix = Nothing
    20. End Function
    Last edited by Tobian; Feb 21st, 2006 at 06:31 AM.

  2. #2

    Thread Starter
    Member
    Join Date
    Feb 2006
    Location
    Holland
    Posts
    34

    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:
    1. Function LookOneBack() As Variant
    2.  
    3. Application.Volatile
    4. LookOneBack = Application.Caller.Offset(0, -1).Value
    5.  
    6. End Function
    Last edited by Tobian; Feb 18th, 2006 at 09:06 AM.

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2006
    Location
    Holland
    Posts
    34

    Re: Run-time Error 424 "Object needed" is bugging me

    Oke solved the bug.

    VB Code:
    1. Public Function ValueOneBack() As Variant
    2.    
    3.     ValueOneBack = ""
    4.    
    5.     Application.Volatile
    6.    
    7.     If TypeName(Application.Caller) = "Range" Then
    8.         If Application.Caller.Row <> 65536 And Application.Caller.Column <> 1 Then
    9.             ValueOneBack = Application.Caller.Offset(1, -1).Value
    10.         End If
    11.     End If
    12.  
    13. End Function
    14.  
    15. Function MatchOneBack() As Integer
    16.     Dim LookupValue As Variant
    17.     Dim rngMatrix As Range
    18.    
    19.     LookupValue = ValueOneBack
    20.    
    21.     Set rngMatrix = Worksheets(1).Range("B1:B4")
    22.        
    23.     If rngMatrix.Find(What:=LookupValue, _
    24.                         LookIn:=xlValues, _
    25.                         LookAt:=xlWhole, _
    26.                         MatchCase:=False) Is Nothing Then
    27.         MatchOneBack = 0
    28.     Else
    29.         MatchOneBack = 2
    30.     End If
    31.        
    32.     Set rngMatrix = Nothing
    33.    
    34. 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
  •  



Click Here to Expand Forum to Full Width