I've been trying out various ways of finding the last row in a range and returning this number to a subroutine, to no avail.
Here's the code I have
Sub StartHere()
Dim oSheet As Worksheet
Set oSheet = WorkSheets(1)
ProcessData(oSheet)
End Sub
Sub ProcessData(ByVal wkst As Worksheet)
Dim rng As Range
Dim lastRow As Long
'set range
Set rng = wkst.Range("L:S") 'Range that i want to process data on
'get the last row (in Long datatype)
lastRow = CLng(getLastRowInRange(rng))
End Sub
Function getLastRowInRange(ByRef rng As Range)
getLastRowInRange = rng.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows,_ SearchDirection:=xlPrevious).Row
End Function
I keep getting Type Mismatch on the
getLastRowInRange = rng.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows,_ SearchDirection:=xlPrevious).Row
Any clues, guys?