-1

I am trying to create a custom function that requires both the Row of the function and the row below it as integers to be used in that function. I tried

Function Row()  
Row = worksheetfunction.excel.row()
End Function

However that returns #Value! in excel. I hope the problem is that I just don't know the syntax to identify the cell I'm putting the formula in and I can use the built in excel row function to get the result.

ZeBeowulf
  • 11
  • 1
  • 1
    Welcome to stackoverflow zeBeowulf. Your question seems to be related to the question here: [link](https://stackoverflow.com/questions/5559279/excel-cell-from-which-a-function-is-called). Use `Application.Caller` as mentioned in the related answer. – RIBH Nov 24 '18 at 19:37
  • or `Application.ThisCell` – Tim Williams Nov 25 '18 at 06:43

1 Answers1

1
Function UDF()
    Dim theRow As Long
    '// Application.Caller is Range
    theRow = Application.Caller.Row
End Function
JohnyL
  • 6,894
  • 3
  • 22
  • 41