I get an error when I code the final line of the Test1 sub. It says “expecting =”. Any ideas?
Sub selectByUsedRows(usedCol As String, selectCol As String)
n = Range(usedCol).End(xlDown).Row
Range(selectCol & "1:" & selectCol & n).Select
End Sub
Sub Test1()
Dim a As String, b As String
a = "A"
b = "B"
selectByUsedRows (a, b)
End Sub
CORRECTED CODE FROM COMMENTS, THANKS!
Sub selectByUsedRows(usedCol As String, selectCol As String)
n = Range(usedCol & "1").End(xlDown).Row
Range(selectCol & "1:" & selectCol & n).Select
End Sub
Sub Test1()
Dim a As String, b As String
a = "A"
b = "B"
selectByUsedRows a, b
End Sub
You’re calling
selectByUsedRowsas if you were calling a function. You don’t need the parentheses when calling a subroutine: