Change
For Each r In Range("a1", Range("a" & Rows.Count).End(xlUp))
to
For Each r In ActiveSheet.UsedRange