Results 1 to 20 of 20

Thread: [RESOLVED] My Public Function only works in a worksheet cel. Versions conflict!

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Location
    Holland
    Posts
    34

    Resolved [RESOLVED] My Public Function only works in a worksheet cel. Versions conflict!

    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:
    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
    Last edited by Tobian; Feb 22nd, 2006 at 10:23 AM.

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