I'm new to vba, but I'm trying to create a function that dynamically finds the range of an entire sheet to be used in other macros for data cleaning.
Here is the function:
Public Function FindRange(Rw As Long, CL As Long)
Dim Rw As Long
Dim CL As Long
CL = ActiveSheet.Cells.Find(What:="*", _
After:=Range("A1"), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
Rw = ActiveSheet.Cells.Find(What:="*", _
After:=Range("A1"), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
End Function
Here is where I'm trying to call it:
Sub Range_Find_Method()
Call FindRange(Rw, CL)
ActiveSheet.Range("A1", Cells(Rw, CL)).Select
End Sub
I keep getting a ByRef argument type mismatch.