if you don't unfilter the range the end(xlup) part will only find the last visible cell-that's why the .autofilter line was added before finding the last cell in the code I supplied