Hi MCheru
Copy the function and sub in a standard module of your workbook
Sub test()
Dim Lr As Long
Dim r As Long
Lr = LastRow(ActiveSheet)
For r = 3 To Lr
'code
Next r
End Sub
Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function
--
Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm
"MCheru" wrote in message ...
How could I change this part (For r = 3 To 500) of a code so that it runs to
the last row in the worksheet instead of just row 500 as it currently does.