CubbyG4M3R
CubbyG4M3R

Reputation: 1

Google Sheets - Move row to new sheet based on drop down value

I have posted this before with my own script and I got some amazing responses but they didn't work fully I am hoping someone can help with a better script

Sample Sheet

The columns will stay the same but I will load data into the area. I am looking to have it when you select the option 'List 1' or 'List 2' or Etc in the Assigned to the column it will move the row to a page with that same name. The new sheets will have the same headers at the top. I can get it to work myself for the one list but I am at a loss for how to make it for multiple lists.

I am hoping to find one that either works on edit or after running the script.

Thanks in advance and please ask any questions I will do my best to answer

Upvotes: 0

Views: 1112

Answers (1)

Cooper
Cooper

Reputation: 64140

Try this:

function onEdit(e) {
  var sh=e.range.getSheet();
  if(sh.getName()=='Your Sheet Name' && e.range.columnStart==6)  {
    var v=sh.getRange(e.range.rowStart,1,1,sh.getLastColumn()).getValues();
    var tsh=e.source.getSheetByName(e.value);
    if(tsh) {
      tsh.getRange(tsh.getLastRow() + 1,1,1,v[0].length).setValues(v);
    }
  }
}

Upvotes: 1

Related Questions