Passing Arguments
Grant,
Like this:
Sub LastRow()
ActiveCell.Formula = FindLastRow("H","Sheet1")
End Sub
Public Function FindLastRow(cell As String, mySh As String) As String
FindLastRow = Worksheets(mySh).Range(cell & Rows.Count).End(xlUp).Row
End Function
HTH,
Bernie
MS Excel MVP
"Grant Reid" wrote in message
...
Hi
As a variation on my previous question. Assume that I have button on
Sheet1.
I want to attach the LastRow macro to this button. What I'm attempting to
establish is to find the last row in a range but on a different sheet, so
I'll need to pass both the column letter and the sheet name.
How can the following code be modified to accomplish this?
Sub LastRow()
Dim val As Integer
val = FindLastRow("H")
ActiveCell.Formula = val
End Sub
Public Function FindLastRow(cell) As String
Dim LastRow
LastRow = Range(cell & Rows.Count).End(xlUp).Row
FindLastRow = LastRow
End Function
Many Thanks - Grant
|