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

Help adding checkbox to google sheets

$
0
0

I am a novice to google app scripts. However I need to copy selected rows (with a checkbox) to a second sheet. I am using this code below. However it copies the entire source sheet. I only need rows that I select to be copied.Can someone please show me how to add a "checkbox" within the script so only the rows I checked are copied. Thanks

Code:

function copyRows() {  var ss=SpreadsheetApp.getActive();  var ssh=ss.getSheetByName("data 1");  var tsh=ss.getSheetByName("Sheet1");  var srg=ssh.getRange(2,1,ssh.getLastRow()+1,ssh.getLastColumn());//assume 1 header row  var svs=srg.getValues();  var trg=tsh.getRange(2,1,tsh.getLastRow()+1,1);//assume 1 header row  var tvs=trg.getValues().map(function(r){return new Date(r[0]).valueOf();});  svs.forEach(function(r,i){//if it is not in the target then append it to the target    if(tvs.indexOf(new Date(r[0]).valueOf())==-1) {      tsh.appendRow(r);    }  });}

Note: my header does not contain a date column as mentioned below. However I will ask questions on that later.


Viewing all articles
Browse latest Browse all 9782

Trending Articles



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