I use this method of finding the last row of data, and this particular method works for my purpose:
Range("A" & Rows.Count).End(xlUp).Row
I also made a form button that links to a macro called Button1_Click(). At the click of this button I'd like to get the last row of data for 3 Excel sheets stored into variables LastRow1, LastRow2, and LastRow3. So assuming I have 3 sheets, and the last row of data on Sheet1 is 5, Sheet2 is 13, and Sheet3 is 84, LastRow1 should equal 5, LastRow2 should equal 13, and LastRow3 should equal 84.
Sub Button1_Click()
LastRow1 = LastRow
End Sub
Function LastRow() As Long
Range("A" & Rows.Count).End(xlUp).Row
End Function
I don't know how to "pass" the name of Sheet1 into the LastRow function and have it spit back the last row so that I can assign the row number to variables LastRow1, LastRow2, and LastRow3.