Results 1 to 19 of 19

Thread: [RESOLVED]VBA-EXCEL How to work with R1C1

Hybrid View

  1. #1
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: VBA-EXCEL How to work with R1C1

    Try this. You will have to change the value of the rngMatrix variable to your named range.


    VB Code:
    1. Function tobian(ByVal LookupValue As Variant) As Long
    2. Dim rngMatrix As Range
    3.  
    4.         Set rngMatrix = ThisWorkbook.Worksheets(1).Range("B4:C11")
    5.        
    6.         If rngMatrix.Find(What:=LookupValue, _
    7.                             LookIn:=xlValues, _
    8.                             LookAt:=xlWhole, _
    9.                             MatchCase:=False) Is Nothing Then
    10.             tobian = 0
    11.         Else
    12.             tobian = 2
    13.         End If
    14.        
    15.         Set rngMatrix = Nothing
    16. End Function
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  2. #2

    Thread Starter
    Member
    Join Date
    Feb 2006
    Location
    Holland
    Posts
    34

    Re: VBA-EXCEL How to work with R1C1

    I tried the function tobian but it don't work the way I expected.
    I changed the range of rngMatrix to mine. But I have to give the function a value to look for. There is no need for.
    Example: when function Tobian is inserted in cell C3, I want the function to match the value of cell B4 with the rngmatrix and put the result "2" or "0" back in cell C3. When I insert the function in cell Y7, the function has to match the value in cell X8.
    I tried to rebuild the function but the R[-1]C[1] gives SyntaxError.

    VB Code:
    1. Function tobian()
    2. Dim rngMatrix As Range
    3.  
    4.         Set rngMatrix = ThisWorkbook.Worksheets(1).Range("B1:B5")
    5.        
    6.         If rngMatrix.Find(What:=R[-1]C[1], _
    7.                             LookIn:=xlValues, _
    8.                             LookAt:=xlWhole, _
    9.                             MatchCase:=False) Is Nothing Then
    10.             tobian = 0
    11.         Else
    12.             tobian = 2
    13.         End If
    14.        
    15.         Set rngMatrix = Nothing
    16.  
    17. End Function
    Last edited by Tobian; Feb 16th, 2006 at 01:47 PM.

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