Video není dostupné.
Omlouváme se.

How to Copy Row from Sheet to Sheet using Google Apps Script on Google Sheets

Sdílet
Vložit
  • čas přidán 18. 08. 2024

Komentáře • 35

  • @she_hoopstoo
    @she_hoopstoo Před 3 lety

    I've been searching the web for quite a bit of time to find this script and your video explained it so clearly and was easy to follow in just a matter of minutes. Thanks so much!

    • @she_hoopstoo
      @she_hoopstoo Před 3 lety

      Sorry for double commenting on your post, but seriously... I've been searching for hours on how to copy a row, paste it to a new sheet and then delete the row from the old sheet for a few hours now. After watching this video and your "How to Clear, Delete, Insert, and Replace Row using Google Apps Script on Google Sheets" video, I was able to create the my script in less than 10 minutes. Thank you so much!

  • @linusjohansson1774
    @linusjohansson1774 Před 4 lety

    I have been searching a while for this information, thanks a lot, great video

  • @CodeWithCurt
    @CodeWithCurt  Před 4 lety +2

    Code in Video Below:
    function CopyRow() {

    var ss = SpreadsheetApp.getActiveSpreadsheet();

    var menuSheet = ss.getSheetByName("Menu");
    var inventorySheet = ss.getSheetByName("Inventory");

    menuSheet.getRange("A5:C1000").clear();

    var partNumber = menuSheet.getRange(1,1).getValue();

    var lastRow = inventorySheet.getLastRow() + 1;
    var foundRecord = false;

    for(var j = 2; j < lastRow; j++)
    {
    if(inventorySheet.getRange(j,1).getValue() ==partNumber)
    {
    var nextRow = menuSheet.getLastRow() +1;
    var getCopyRange = inventorySheet.getRange('A' + j + ':C' + j);
    getCopyRange.copyTo(menuSheet.getRange(nextRow, 1));
    foundRecord = true;
    }
    }

    if(foundRecord == false)
    {
    menuSheet.getRange(5,1).setValue(['(NO RECORDS FOUND)']);
    }
    }

    • @arandomcoder101
      @arandomcoder101 Před 3 lety

      Pin your comment so that it stays above others comment and no one misses it.

  • @stwk8
    @stwk8 Před 3 lety +2

    Hi Curt!,
    This is very helpful for me!. However, after using this and attach to a button
    When I have data of 100 rows, button is needed to click several times to execute call.
    Is there any method that can use ur function to execute by a single click.

  • @MrSarahqputra
    @MrSarahqputra Před 3 lety +2

    Hi, thanks for the great video.
    Can we replace the row of data but determine by date (today()) in another sheets.
    So the set values not on the last row but within the data, the new data will replace the old data but determined by date today.

  • @sarthakbakhri2200
    @sarthakbakhri2200 Před 3 lety +1

    thanks its working

  • @DJJeSta09
    @DJJeSta09 Před rokem

    Hey Curt. Just watching your video to get an idea of a copy function. Basically for mine i am trying to copy 3 specific cells values (H7:J7) and past them on the same sheet in the next available row in columns C,D,E. i am fairly new to this but is there a video that you do that comes closer to what i am attempting do?

  • @fernandoriveros1372
    @fernandoriveros1372 Před 4 lety

    Hello Curt! Nice video, very informative. I have tried to find a script that copy values from one sheet to another in google sheets, but the values are in different cells and in different columns. What I want is to get all that values and copy to destination sheet in one single row. Is there a function or sometning to do that?

  • @meghanpfeiffer
    @meghanpfeiffer Před 7 měsíci

    Figured out how to do this for my sheet and thought a second example might be helpful if you were struggling like I was:
    function AddtoTimeSheet() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var inputSheet = ss.getSheetByName("Input");
    var timeSheet = ss.getSheetByName("Time Sheet");
    var requiredTest = inputSheet.getRange('B17');
    if (requiredTest == 'Good') {
    var nextRow = timeSheet.getLastRow() +1;
    var getCopyRange = inputSheet.getRange('C2');
    getCopyRange.copyTo(timeSheet.getRange(nextRow, 1));
    var getCopyRange = inputSheet.getRange('C4');
    getCopyRange.copyTo(timeSheet.getRange(nextRow, 3));
    var getCopyRange = inputSheet.getRange('C6');
    getCopyRange.copyTo(timeSheet.getRange(nextRow, 5));
    var getCopyRange = inputSheet.getRange('C8');
    getCopyRange.copyTo(timeSheet.getRange(nextRow, 2));
    var getCopyRange = inputSheet.getRange('C10');
    getCopyRange.copyTo(timeSheet.getRange(nextRow, 4));
    inputSheet.getRange("C2:C10").clear();
    } else {
    inputSheet.getRange('C12').setValue(['Error']);
    }
    }

  • @rohitkumawat6416
    @rohitkumawat6416 Před rokem

    Hello Curt,
    Can we update same data(like column name, formula etc...) of many google sheets at a time using only one google sheet's app script? If yes then how? Please make a video

  • @123alm3
    @123alm3 Před 3 lety +2

    How i chose one row range?

  • @AbeerJha_21
    @AbeerJha_21 Před 3 lety

    Hi gr8 work , sorry I didn't get code in any comments

    • @CodeWithCurt
      @CodeWithCurt  Před 3 lety

      If you can see the comment try this:
      -In the comments section, try clicking on 'SORT BY' then clicking 'NEWEST FIRST' and see if they show up.

  • @Jason-cp7ge
    @Jason-cp7ge Před 3 lety

    Hi , Can you copy a row with formulas from the Source sheet and dynamically paste it to a variable row within the range in the Target Sheet. Note: The target row is variable because data are constantly being added.

    • @Jason-cp7ge
      @Jason-cp7ge Před 3 lety

      Good day Curt, Hope you can provide the scripts. Really appreciate it. Thank you!!

  • @ivaniusblog2762
    @ivaniusblog2762 Před 2 lety +1

    How to copy new data from SHEET A to a next blank row in SHEET B? The data from Sheet A can be deleted and new data copied from SHEET A on SHEET B should remain intact. Anyone knows how to do it? ThaNks

  • @michaelhien9152
    @michaelhien9152 Před 3 lety

    hi, what if I only want to populate the data from row 13 to row 22, not from the last row like in video?

  • @ahmedfizah7408
    @ahmedfizah7408 Před 11 měsíci

    Can we copy the column headers too?

  • @efcdatasupport6375
    @efcdatasupport6375 Před 3 lety

    Hi i want to add data in the last row, how can be possible

  • @GASP2.0
    @GASP2.0 Před 3 lety

    Sir please make a video importrange formula in script

  • @tedstapenhorst2134
    @tedstapenhorst2134 Před 3 lety

    Hi Curt,
    Great video. I'm trying to copy one tab's (tab1) values to another tab (tab2) in the same spreadsheet. If column 2 has a certain string value I don't want to copy that entire row. How could I rewrite the IF statement in your script if column 2 contains an invalid string and I can avoid copying the entire row from tab1 to tabl2?
    Thank you in advance.

    • @CodeWithCurt
      @CodeWithCurt  Před 3 lety

      On line 17:
      inventorySheet.getRange(j,1).getValue() == partNumber
      You could add an 'and' condition with this:
      && inventorySheet.getRange(j,2).getValue() != someString

    • @tedstapenhorst2134
      @tedstapenhorst2134 Před 3 lety

      Thank you Curt.

  • @JustFlav
    @JustFlav Před 2 lety

    Good morning! Could you please give me the script to make +1 of a cell each time a button is clicked? Thank you so much ! : D

  • @gsdcgsdc9976
    @gsdcgsdc9976 Před 2 lety

    Hi. Would like to ask if you can give me script for the generation of number starting from 1 to 1000000 that I can use for automatic generation of Request #.

  • @luuminhvuong
    @luuminhvuong Před 4 lety

    Vs importrange . Which one better

    • @CodeWithCurt
      @CodeWithCurt  Před 4 lety

      In this video I am just showing you how you can accomplish this task with google apps script. I am sure both ways works fine depending on what application you are building.

  • @joaquindonesconsulting9524

    Is there a link to this script somewhere?

  • @vaibhavvishal1320
    @vaibhavvishal1320 Před 4 lety

    script to this code?

  • @jacquesparadis6756
    @jacquesparadis6756 Před 2 lety

    Hi Kurt! Great work. thanks! Wonder if you could give me a Quick hand. Here is the thing. From Sheet1 which receives data from a GG form, I want to copy the last row of data from column 2 to let’s say column 6. Go to Sheet2 and paste « Values » in the first available empty row. I will run this script from a button. Hope you find the time to give me a quick heads up. Best. Jacques