==============FIXED==========
I have a function:
Public Function getLastRow(sheetName As String) As Integer
getLastRow = Worksheets(sheetName).Cells(Rows.count, 1).End(xlUp).row
End Function
When I try to use that function . . .
Sub test()
MsgBox getLastRow("Data")
End Sub
. . . I get a subscript out of Range (run-time error '9') error. How can I make the error go away?
running getLastRow = Worksheets("Data").Cells(Rows.count, 1).End(xlUp).row works fine. But I want to be able to dynamically choose the sheet name in my function.