In excel vba projects I often use a function to find the last row of data on a given sheet...
Code: Select all
Function LastRow(targetSheet As Worksheet, Optional targetCol As String = "A")
With targetSheet
LastRow = .Cells(.Rows.Count, targetCol).End(xlUp).row
End With
End Function
Code: Select all
'Retrieves a cell value from the specified worksheet
Function GetCell(Sheet,Row,Column)
Dim xlSheet
Dim xlLastRow
Dim xlColumn
Set xlSheet = xlBook.Worksheets("MySheet")
Set xlColumn = Column
Set xlLastRow = xlSheet.Cells(.Rows.Count, xlColumn).End(xlUp).Row
GetCell = xlSheet.Cells(Row, Column).Value
End Function