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,020 points
754 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,720 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,795 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
506 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
408 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,720 points
1,856 views
0 votes
1 answer

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

This seems to be a potential duplicate ...READ MORE

answered Oct 22, 2022 in Others by narikkadan
• 63,720 points
1,294 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,720 points
1,182 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,107 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,100 points
1,027 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,720 points
1,952 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,720 points
1,035 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