Alternatively you can use this:

[VBA]
lastrow = Range("A1").End(xlDown).Offset(1, 0).Row
[/VBA]

Instead of using this:

[VBA]lastrow = Range("A65536").End(xlUp).Offset(1, 0).Row [/VBA]

The first way starts at the top and works its way down until it finds the last populated row. The second way starts at "A65536" and works its way up to find the last populated row.