Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

How to identify specific data in a column in AppScript

$
0
0

I'm doing my first App Scripts and I'm able to have them working... but I remain dependant on some Sheets formulas to identify data. This impacts the speed of my script dramatically.

As a basic example, lets pretend I want to delete every lines that have a "-" in a certain column. I don't know how to identify "-" in a column in App Script so I did this formula in my Helper spreadsheet:

=IFERROR(MATCH("-",Database!$U:$U,0),0)

Then I retrieve this information in my code and recalculate the workbook after each deletion to have the new Match value:

function deleteNoValue(){  var ss = SpreadsheetApp.getActive();                 // Thisworkbook  var ssHlp = ss.getSheetByName('Helper');             // Sheet with match formula  var ssDb = ss.getSheetByName('Database');            // Sheet to delete lines from  var firstNoVal = ssHlp.getRange('A1').getValue();    // Match formula value  while (firstNoVal != 0) {                            // Repeat until all lines deleted    ssDb.deleteRows(firstNoVal ,1);                    // Delete line    SpreadsheetApp.flush();                            // Wait for Match to refresh value    firstNoVal = ssHlp.getRange('A1').getValue();      // Get new value  }}

How can I have this improved without needing the help of Sheets formulas to be refreshed?


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>