I need to move the rows from a single worksheet into multiple destination sheets based on a variety of criteria. I figure using filters + copy/paste would be way faster than looping over each row and examining it to see where it belongs, but I’m not sure how to get a usable range after the data is filtered. Right now, I’m making a range of visible cells to grab like so:
Set rngSuspect = ActiveSheet.Cells.SpecialCells(xlVisible)
then pasting it like so (
NextRow is an
Integer holding the next blank row number):
rngSuspect.Cut Destination:=Sheets("Suspect WWAs").Rows(NextRow)
This fails with the message
The command you chose cannot be performed with multiple selections. Select a single range and click the command again. I assume it has to do with the fact that the data is actually split into multiple areas because of the filtered rows. I’d rather not loop over each row in the range and move them individually. Surely there’s a more elegant solution here…
A workaround to keep your code : you cannot cut multiple selection but you can copy it. Then, you delete it as a cut would have done.
The workaround I have is to sort the sheet so that all the rows you need to cut or copy become adjacent. A fairly complex sort may be needed, but then you can apply the filter and the rows should remain adjacent and can be safely cut or copied with the usual visible selection code.