0

I am still learning javascript so excuse me for probably a stupid question. I searched for the title of my question and the closest I found was this link: Google Sheets copy and paste row into another sheet and then delete content from the first sheet

What I need to do is to search for the word "Kicked" in this google sheet: https://docs.google.com/spreadsheets/d/1UM3sZ3AK6_-khzfNgyyYesn56DrkKS2zSV20zorzpPg/edit?usp=sharing from columns F to AJ in rows 2 to 101 so my search range is F2:AJ101.

the current code I use in the script is as follows:

function onEdit(e) {    
var sheet=e.range.getSheet();
if (sheet.getSheetName() == 'Test') {
  logSheet = e.source.getSheetByName('Kicked');
  var row = e.range.getRow(); 
  var lastRow = logSheet.getLastRow();
  var range = sheet.getRange(row, 1, 1, sheet.getLastColumn()); 
  range.copyTo(logSheet.getRange(lastRow+1,1),{contentsOnly:true});
  sheet.clearContent();
}

} }

However, the code does not empty the row once it is copied to the new sheet. If anyone can help me, I would really appreciate it.

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • Welcome. What error message do you get? In any event, your code isn't tailored to your requirements at all: it doesn't actually test for the search value; and `clearContent()` is a range command, not a sheet command-`range.clearContent();` is more likely to work. In addition, though you supplied your spreadsheet, you disabled "Export options", which means that no-one can actually test any code against your data. Have a look at [Find Cell Matching Value And Return Rownumber](https://stackoverflow.com/questions/32565859/). – Tedinoz Jan 18 '19 at 13:02
  • 2
    Possible duplicate of [Find Cell Matching Value And Return Rownumber](https://stackoverflow.com/questions/32565859/find-cell-matching-value-and-return-rownumber) – Tedinoz Jan 18 '19 at 13:03
  • As a matter of fact, the code works pretty fine. Except for the clear function. When i get on my pc I will enable editing for whoever has the link so you can test a code. – Mahmoud Sayed Jan 19 '19 at 17:41

0 Answers0