Move A Row to Different Spreadsheet - Google Apps Script Tutorial

Поділитися
Вставка
  • Опубліковано 7 вер 2024
  • In this video, I quickly demonstrate and explain how to put together a Google Sheet and the App Script to be able to quickly move rows of data between tabs using a dropdown status.
    If you want to make a copy of the Google Sheet and script I used in the video, check it out here:
    bit.ly/3zaQiWk

КОМЕНТАРІ • 12

  • @JosephJericoMarino
    @JosephJericoMarino Місяць тому

    I have an error, the let range = e.range;
    TypeError: Cannot read properties of undefined (reading 'range')

    • @SheetsNinja
      @SheetsNinja  Місяць тому

      That will happen when you authorize the script, because the onEdit is designed to run when the spreadsheet is edited and then "e" will contain info about the edit event that caused it to run. So the script should run now if you make an edit in the Google Sheet.

    • @mahdiNJR13
      @mahdiNJR13 20 днів тому

      add trigger

  • @laganjsl5817
    @laganjsl5817 5 місяців тому +1

    Hello Sir, thanks for this tutorial video, but i have an issue, why data thats been moved to target sheet becomes duplicate? im following all way that you show on video

    • @SheetsNinja
      @SheetsNinja  5 місяців тому

      Typically if you have an issue with duplicates, it's when multiple edits are being made to the sheet, and so the script is running multiple times at the essentially same time. If there are multiple people in the Google Sheet at the same time, you might have to take a different approach and run a script at night to make the necessary transfers.
      Otherwise another approach is to use a script lock so its only running one at a time, but if you have multiple people making edits at the same time, this can also result in some weird and unexpected behavior.

  • @user-xi6ys2op9m
    @user-xi6ys2op9m 9 місяців тому +1

    Hey there, what happens if you make a mistake and want to get the row back to the master list?

    • @SheetsNinja
      @SheetsNinja  9 місяців тому +1

      You'd have to add the script to the sheet it got moved to as well, and then basically take the same action on the target sheet

    • @user-xi6ys2op9m
      @user-xi6ys2op9m 9 місяців тому

      @@SheetsNinja thanks for the prompt response!

  • @prakashshrestha3430
    @prakashshrestha3430 11 місяців тому

    hello sir, i have problem to move data on protected sheet and last data move to top in next sheet so please help me.

    • @SheetsNinja
      @SheetsNinja  11 місяців тому

      So if you don't have edit access to a sheet or tab, all you can do is copy data, not move it. If you want to copy the last row from a tab and move to the top of the next sheet, you'll just want to use this:
      let data = sourceSheet.getRange(sourceSheet.getLastRow(),1,1, sourceSheet.getLastColumn()).getValues();
      targetSheet.insertRowBefore(2)
      targetSheet.getRange(2,1,1,data[0].length).setValues(data);

  • @dnaml168
    @dnaml168 Рік тому

    HI, I want to ask you if I want to copy to other sheet , but keep old data

    • @SheetsNinja
      @SheetsNinja  Рік тому +1

      All you do is remove the line of code that says:
      sheet.deleteRow(row);