Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Apps Script form copy row with matching criterion need assistance. Script works with caveat

I posted this script on another website but didn't get an answer that worked for me. Script at the end of post.

I am working on a google sheets form response that will have multiple tabs on it. I want to sort each response based on a dropdown in column 2 with corresponding tab name and checkbox in column 1 is checked. My code below copies each row based on checkbox without any problems. I just need to add for dropdown match and copy to that corresponding tab. I was thinking an array might work but I couldn't seem to get the proper outcome. Thanks for the help. I can clarify my issues if need be.

function onEdit(event) {
// getColumn with check-boxes is currently set to column 1 OR A
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName('Testing');
var r = event.source.getActiveRange();
// if(r.getColumn() == 2 && r.getValue() == "Page 1") {
if(r.getColumn() == 1 && r.getValue() == true) {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Copied");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 2, 1, numColumns).copyTo(target, {contentsOnly:true});
s.deleteRow(row);
}
}
}

Sample sheet link https://docs.google.com/spreadsheets/d/1befqsGQvbPfn0XTGrygLOGcrUIMrICUagJVH0S-2rDw/edit?usp=sharing

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It can be done this way:

function onEdit(event) {
  // getColumn with check-boxes is currently set to column 1 OR A
  var ss = event.source;
  var s = ss.getSheetByName('Testing');
  var r = event.source.getActiveRange();
  if (r.getColumn() == 1 && r.getValue() == true) {
    var row = r.getRow();
    var numColumns = s.getLastColumn();
    var targetSheet = ss.getSheetByName("Copied");
    var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
    s.getRange(row, 2, 1, numColumns).copyTo(target, { contentsOnly: true });

    var page = s.getRange(row, 2).getValue(); // get the sheet name from column B
    var pageSheet = ss.getSheetByName(page); // target sheet
    var target = pageSheet.getRange(pageSheet.getLastRow() + 1, 1); // target range
    s.getRange(row, 2, 1, numColumns).copyTo(target, { contentsOnly: true }); // copy to the target

    s.deleteRow(row);

    ss.toast('Row ' + row + ' was copied to ' + page);
  }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!