title: Custom Function using a Sheet name as a parameter
body: <p>I have a function like this:</p>
  
  <pre><code>Function GetLastRowOnSheet(ByVal SheetName As Worksheet) As Long
      On Error Resume Next
      GetLastRowOnSheet = SheetName.Cells.Find(what:="*", after:=SheetName.Cells(1),     searchorder:=xlByRows, searchdirection:=xlPrevious).Row
      On Error GoTo 0
  End Function
  </code></pre>
  
  <p>Lets say I have a sheet called "Sheet1", in my excel sheet, <strong>I would like to be able to say =GetLastRowOnSheet('Sheet1')</strong> or use a <strong>named range</strong></p>
  
  <p>I can do this easily in vba using the function above as well as a subroutine or function that includes this:</p>
  
  <pre><code>Dim Sheet1 As Worksheet
  Dim LastRow as Long
  Set Sheet1 = ThisWorkbook.Sheets("Sheet1")
  LastRow = GetLastRowOnSheet(Sheet1)
  
  ' last row then returns the last filled in cell on the sheet
  </code></pre>
  
  <p>Thoughts?</p>