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

preview_player
Показать описание
This video shows how to copy a row of data from one sheet to another using Google Apps Script. This video also shows how to search a column on Google Sheets.

Apps Script Code can be found at:

Legacy Apps Script Editor Used in Video

Apps Script (Script Editor) is now located under tab ‘Extensions’ instead of ‘Tools’ on Google Sheets
Рекомендации по теме
Комментарии
Автор

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
Автор

Code in Video Below:

function CopyRow() {

var ss =

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



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)']);
}
}

CodeWithCurt
Автор

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.

stwk
Автор

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.

MrSarahqputra
Автор

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?

DJJeSta
Автор

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

linusjohansson
Автор

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?

fernandoriveros
Автор

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

rohitkumawat
Автор

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.

tedstapenhorst
Автор

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

michaelhien
Автор

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

JustFlav
Автор

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-cpge
Автор

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

efcdatasupport
Автор

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

ivaniusblog
Автор

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

gsdcgsdc
Автор

Is there a link to this script somewhere?

joaquindonesconsulting
Автор

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

AbeerJha_
Автор

Sir please make a video importrange formula in script

GASP.
Автор

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 =

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));


} else {

}
}

meghanpfeiffer
Автор

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

jacquesparadis
join shbcf.ru