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

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

Code With Curt

4 года назад

36,334 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@meghanpfeiffer
@meghanpfeiffer - 13.01.2024 04:10

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

Ответить
@ahmedfizah7408
@ahmedfizah7408 - 22.09.2023 19:17

Can we copy the column headers too?

Ответить
@rohitkumawat6416
@rohitkumawat6416 - 28.03.2023 15:38

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

Ответить
@DJJeSta09
@DJJeSta09 - 12.01.2023 21:02

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?

Ответить
@ivaniusblog2762
@ivaniusblog2762 - 11.05.2022 15:39

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

Ответить
@gsdcgsdc9976
@gsdcgsdc9976 - 14.03.2022 08:42

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 #.

Ответить
@JustFlav
@JustFlav - 07.12.2021 04:22

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

Ответить
@jacquesparadis6756
@jacquesparadis6756 - 19.09.2021 01:47

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

Ответить
@MrSarahqputra
@MrSarahqputra - 26.05.2021 01:12

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.

Ответить
@123alm3
@123alm3 - 17.05.2021 16:16

How i chose one row range?

Ответить
@sarthakbakhri2200
@sarthakbakhri2200 - 15.04.2021 15:36

thanks its working

Ответить
@efcdatasupport6375
@efcdatasupport6375 - 12.04.2021 19:43

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

Ответить
@stwk8
@stwk8 - 27.02.2021 12:25

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.

Ответить
@michaelhien9152
@michaelhien9152 - 21.02.2021 14:25

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

Ответить
@naveensurya546
@naveensurya546 - 20.01.2021 20:48

Could you please help me 😭 I'm struggling a lot
I need solution for my problem.

I have data having in single cell i.e
[Invoice I'd ][ product ID's][all item's][ all item's quantity][ item's price]

Ex:
[7085][432,444,456][item1,item2,item3][1,2,1][$10,$30,$10]

Consider [ ] as single cell

I want output in row wise
Like

[7085][432][item1][1][$10]
[7085][444][item2][2][$30]
[7085][456][item3][1][$10]

I'm already tried
Split and TRANSPOSE(SPLIT ())
Tried to create custom functions but I failed 😔
Please suggest any other ways to achieve required output

I have huge data I'm not able to do this process manually so I'm trying to find dynamic ways please help me 🙏🙏


Thank you ❤️

Ответить
@Jason-cp7ge
@Jason-cp7ge - 19.01.2021 10:10

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.

Ответить
@GASP2.0
@GASP2.0 - 26.10.2020 17:29

Sir please make a video importrange formula in script

Ответить
@tedstapenhorst2134
@tedstapenhorst2134 - 26.10.2020 01:41

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.

Ответить
@ernestoflores6609
@ernestoflores6609 - 09.10.2020 06:47

var ss = SpreadsheetApp.getActiveSpreadsheet();

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

menuSheet.getRange(A1:B1").clear();

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

var lastRow = inventorySheet.getRange(1, 1).getValue();
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')];

}

Ответить
@kaushalkishor1
@kaushalkishor1 - 03.10.2020 16:26

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

Ответить
@she_hoopstoo
@she_hoopstoo - 15.09.2020 07:15

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!

Ответить
@vaibhavvishal1320
@vaibhavvishal1320 - 07.09.2020 06:31

script to this code?

Ответить
@luuminhvuong
@luuminhvuong - 03.09.2020 18:04

Vs importrange . Which one better

Ответить
@CodeWithCurt
@CodeWithCurt - 15.08.2020 19:45

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

Ответить
@joaquindonesconsulting9524
@joaquindonesconsulting9524 - 15.08.2020 04:13

Is there a link to this script somewhere?

Ответить
@fernandoriveros1372
@fernandoriveros1372 - 07.08.2020 01:34

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?

Ответить
@linusjohansson1774
@linusjohansson1774 - 08.06.2020 00:09

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

Ответить