i sorted alphabetically at the end as this gets rid of the spaces, you could get rid of this and delete out all the blankrows if you like replace
Range("A1:A" & Lastrow).EntireRow.Sort Range("A1")
with
Range("A1:A" & Lastrow).specialcells(xlcelltypeblanks).entirerow. delete
dave