When there are only a few rows of data to eliminate, my script works perfectly. However, when the dataset grows, it becomes unusable and slower. It takes several hours to delete 50 table rows. As I can see it deleting one row at a time, I believe the loop that goes through each address in the array is slowing things down. I'm not sure whether there is a way to remove every entry from the array without using a loop, though.
const rowAddressToRemove = rangeView.getRows().map((r) => r.getRange().getAddress());
rowAddressToRemove.splice(0, 1);
const sheet = sourceTable.getWorksheet();
rowAddressToRemove.reverse().forEach((address) => {
sheet.getRange(address).delete(ExcelScript.DeleteShiftDirection.up);
});
The current code is functional, but it is quite slow. I believe that my code may have been improperly optimized in several areas, which is why it is so unusable.
Here is an example of the rowAddressToRemove variable output on the console:
(2) ["Pending!A7:G7", "Pending!A8:G8"] 0: "Pending!A7:G7" 1: "Pending!A8:G8"