Is there a faster way to delete table rows so my script doesn t take hours to run

0 votes

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"
Jan 31, 2023 in Others by Kithuzzz
• 38,000 points
811 views

1 answer to this question.

0 votes

This is for your rowAddressToRemove variable. So instead of having code like:

    const rowAddressToRemove = rangeView.getRows().map((r) => r.getRange().getAddress());

You can have code like this:

    const rowAddressToRemove = rangeView.getRange().getAddress()

So you can try to see if this makes things faster. If it doesn't, it may also have to put the code for your rangeView variable in the post as well.

answered Jan 31, 2023 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

Is there a way to search the iOS app store online?

Apple finally made it possible to just use ...READ MORE

answered Sep 21, 2022 in Others by rajatha
• 7,680 points
3,929 views
0 votes
1 answer

Is there a way to generate high resolution PNGs of iOS emoji?

Step 1: Visit Google Play Store on ...READ MORE

answered Nov 4, 2022 in Others by gaurav
• 23,260 points
575 views
0 votes
0 answers

Is there a way to generate high resolution PNGs of iOS emoji?

I have been able to find 160x160 ...READ MORE

Sep 23, 2022 in Others by gaurav
• 23,260 points
478 views
0 votes
1 answer

Is there a way in Microsoft Excel to give specific bins different bin widths when making a histogram plot?

Excel built-in histogram tool only allows equal ...READ MORE

answered Oct 2, 2022 in Others by narikkadan
• 63,600 points
1,985 views
0 votes
1 answer

Excel create an Index on the first sheet with links to subsequent sheets

Below example shows how to use the ...READ MORE

answered Oct 22, 2022 in Others by narikkadan
• 63,600 points
1,382 views
0 votes
1 answer

Pass multiple Excel cell values to Power Automate

If you have certain data that you ...READ MORE

answered Nov 20, 2022 in Others by narikkadan
• 63,600 points
1,270 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,212 views
0 votes
1 answer

ImportError: openpyxl is required for loading excel format files

Forget the PsychoPy complications for the time ...READ MORE

answered Oct 3, 2018 in Python by Priyaj
• 58,020 points
1,079 views
0 votes
1 answer

Is there any way in python to auto-correct spelling mistake in multiple rows of an excel files of a single column?

Use Spellchecker for doing your stuff: import pandas ...READ MORE

answered Oct 14, 2022 in Others by narikkadan
• 63,600 points
2,054 views
0 votes
1 answer

Is there a way to SUMIFS with multiple criteria + true or false?

You can add this as the  last criteria: =SUMIFS(STORE!$C$6:$C$1000;STORE!$A$6:$A$1000;""&SUMMARY!$D$5&"";STORE!$D$6:$D$1000;""&SUMMARY!$C$9&"";STORE!$E$6:$E$1000;""&SUMMARY!D8&"";STORE!$AA$6:$AA$1000;TRUE) STORE!$AA$6:$AA$1000: ...READ MORE

answered Oct 1, 2022 in Others by narikkadan
• 63,600 points
1,080 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP