Members-only tutorial

Watch the video and get the practice sheet with membership.

See membership options

Copy That, From One Sheet to Another - Learn to Code in Google Sheets Part 4

About this Tutorial

Learn to code in sheets. Automate Your Daily Sales Report with Google Sheets: Learn how to create a script that copies data from one sheet to another, including timestamps. Boost your productivity with this easy guide!

Featured Formulas

Video Transcript

<div>0:00 All right, here's part four. We're gonna copy something from one sheet to another. So far we've been writing an app script Explore the power of Apps Script for automating tasks in Google Sheets. Opens in new tab , little things that take, do something right.<br>0:11 And now for the next video to prepare for the next video, we wanna create a script that runs by itself at any time.<br>0:19 It can run any, and it's gonna happen every single day.

So we're gonna create this scenario where Learn how to filter data effectively with the query where clause. Opens in new tab we have a sheet called sales summary and we have a sheet called Sales Log.<br>0:33 Now we use, we'll use this sales summary in a one and every day we're gonna be having the total sales of that day right there.<br>0:41 But we wanna log it here every single day automatically. Now we're gonna create the trigger Discover how to set up triggers to automate your Google Sheets tasks. Opens in new tab . Tomorrow triggers a very interesting word, but today we're going to write the script.<br>0:56 But just before we do the script, let's do one thing and just do what we want it to do.

We wanna take what's on sales summary, A one.<br>1:05 We're gonna copy that. We want it in the A column to paste the values Understand how to work with values in Google Sheets for accurate data handling. Opens in new tab no matter what. If we have a formula Get familiar with the syntax used in Google Sheets formulas and scripts. Opens in new tab there or anything, we just want the value.<br>1:14 And here we want something like now, like a timestamp Learn how to add timestamps to your Google Sheets for better tracking. Opens in new tab . So I'm gonna copy this and paste the value. Now this could be just formatted in another way.<br>1:23 Number Explore number formatting options in Google Sheets for clearer data presentation. Opens in new tab date time, right? So this is the end result.

And then the next day on, we want whatever sales we had that day in that same spot we wanted to copy here.<br>1:37 So there's a few things we have to do, but first let's just jump into our up script and see what's going on.<br>1:43 So we have all of our script from before that we did. Let's just move that all down. We're gonna write a new function Dive into functions in Google Sheets to perform complex calculations easily. Opens in new tab .<br>1:50 Again, this function Dive into functions in Google Sheets to perform complex calculations easily. Opens in new tab needs to happen every single day. We wanna call it copy sales data Understand data types and how to manage them in Google Sheets. Opens in new tab , sales data Understand data types and how to manage them in Google Sheets. Opens in new tab to sales log.<br>1:59 That's just the name of it. We can really name it anything we want.

We're gonna create the curly brackets, we've got the parenthesis, the curly brackets, and inside we're gonna write some comments Learn how to add comments in Google Sheets for better collaboration. Opens in new tab .<br>2:11 These are two slashes and then some text. And this gives us the ability to write in real words to ourselves notes Discover how to use notes in Google Sheets to keep track of important information. Opens in new tab as how do we want to break this down?<br>2:22 We want to get the data Understand data types and how to manage them in Google Sheets. Opens in new tab from sheet sales summary which in a one we want to copy it to sales log, whatever is the last row.<br>2:46 And so what we can do is we can probably just Google for this kind of stuff.

If we don't know the exact functions Explore various functions available in Google Sheets for enhanced productivity. Opens in new tab , we could probably just type in Google Script and copy two or copy two a sheet.<br>2:57 And what we're gonna find is we're gonna have the copy two function Dive into functions in Google Sheets to perform complex calculations easily. Opens in new tab and it needs a destination and it has some options that we can put into it, into that function Dive into functions in Google Sheets to perform complex calculations easily. Opens in new tab .<br>3:07 And we also want to paste values Learn how to paste values in Google Sheets to avoid formula issues. Opens in new tab , which we found out if you did that. Google search is the option of content only true.<br>3:21 And then once once we have this paced values Understand how to work with values in Google Sheets for accurate data handling. Opens in new tab , right? And we have a timestamp Learn how to add timestamps to your Google Sheets for better tracking. Opens in new tab , we will also want a timestamp Learn how to add timestamps to your Google Sheets for better tracking. Opens in new tab in column call.<br>3:38 How do you spell Callum? Lum B.

So we can save this text. This doesn't do anything, literally doesn't do anything using this slashes comments Learn how to add comments in Google Sheets for better collaboration. Opens in new tab out.<br>3:50 But first, let's just get a variable data Understand data types and how to manage them in Google Sheets. Opens in new tab . And we know this from the last video. Spreadsheet Get to know the basics of spreadsheets and their functionalities. Opens in new tab app dot get active spreadsheet Understand how to reference the active spreadsheet in your scripts. Opens in new tab .<br>4:00 Remember the parentheses get sheet by name. The sheet is going to be sales summary dot get range Learn about ranges in Google Sheets and how to manipulate them effectively. Opens in new tab . The range Learn about ranges in Google Sheets and how to manipulate them effectively. Opens in new tab is a one.<br>4:11 Get value. That's gonna get us the data Understand data types and how to manage them in Google Sheets. Opens in new tab . We want to get the sales log.

So variable sales, well actually we can just call it destination sheet equals spreadsheet Get to know the basics of spreadsheets and their functionalities. Opens in new tab .<br>4:27 App dot get active spreadsheet Understand how to reference the active spreadsheet in your scripts. Opens in new tab dot get sheet by name. And here we want sales log. So one thing we could do a last row function Dive into functions in Google Sheets to perform complex calculations easily. Opens in new tab , find last row in sort Discover sorting techniques to organize your data in Google Sheets. Opens in new tab of under that.<br>4:42 But actually we want it to insert into the first row. We want it in reverse chronological order after inserting a row.<br>4:50 So we can go to destination sheet dot insert row Learn how to insert rows in Google Sheets to manage your data better. Opens in new tab before the first row. Then we can say that we want to copy two.<br>5:11 We can find copy two actually here. And let's look at it.

Let's actually look at this one. Copy, two piece type.<br>5:23 Now let's just use this one. So we need a range Learn about ranges in Google Sheets and how to manipulate them effectively. Opens in new tab . We need to know the range Learn about ranges in Google Sheets and how to manipulate them effectively. Opens in new tab , not the values Understand how to work with values in Google Sheets for accurate data handling. Opens in new tab , but the range Learn about ranges in Google Sheets and how to manipulate them effectively. Opens in new tab .<br>5:29 And we copy it to where Learn how to filter data effectively with the query where clause. Opens in new tab it goes to. Cool. That's easy. We know what we're doing here. We're getting this data Understand data types and how to manage them in Google Sheets. Opens in new tab .<br>5:40 We actually don't even need get value, we just need that range Learn about ranges in Google Sheets and how to manipulate them effectively. Opens in new tab . Copy two destination is gonna be this destination sheet.<br>5:52 In this case, we do need a range Learn about ranges in Google Sheets and how to manipulate them effectively. Opens in new tab get range. We want it row one, column one. And then we want to put in this, in the options content's only.<br>6:07 True.

We only want the number Explore number formatting options in Google Sheets for clearer data presentation. Opens in new tab . And for the timestamp Learn how to add timestamps to your Google Sheets for better tracking. Opens in new tab , we do variable timestamp Learn how to add timestamps to your Google Sheets for better tracking. Opens in new tab equals new date. And then all we need to do is spreadsheet Get to know the basics of spreadsheets and their functionalities. Opens in new tab , app dot, get active spreadsheet Understand how to reference the active spreadsheet in your scripts. Opens in new tab , Parentes, get sheet by name.<br>6:26 Sales log dot get range Learn about ranges in Google Sheets and how to manipulate them effectively. Opens in new tab is gonna be one, not sorry, call row one column two, set value. And it's gonna be tap stamp.<br>6:50 So if we go up to our log up here or to run, we wanna run this and just test it out.<br>6:57 So run, gotta get some authorization Understand the authorization process for using Google Sheets scripts. Opens in new tab . We have to do this each time when we create a new spreadsheet Get to know the basics of spreadsheets and their functionalities. Opens in new tab app.

Alright, let's see what happened.<br>7:08 We have this sales summary here of sales log here. Perfect. So it inserted a row and it puts in the timestamp Learn how to add timestamps to your Google Sheets for better tracking. Opens in new tab .<br>7:16 Perfect. So a little bit of meta talking here about programming inside of Google Sheets and Google Script and app Script Explore the power of Apps Script for automating tasks in Google Sheets. Opens in new tab is if you have some data Understand data types and how to manage them in Google Sheets. Opens in new tab , like let's say this is incorrect, right?<br>7:30 We, we typed in a three and we didn't know. We're like, why is this sort Discover sorting techniques to organize your data in Google Sheets. Opens in new tab of working but not working?<br>7:37 It's completing. We can always do logger dot log and look at the data Understand data types and how to manage them in Google Sheets. Opens in new tab .

And what this allows us to do is run it and see right here, we got this range Learn about ranges in Google Sheets and how to manipulate them effectively. Opens in new tab .<br>7:46 Okay, we gotta just get range Learn about ranges in Google Sheets and how to manipulate them effectively. Opens in new tab . So what does that get value? Let's run it and see what that value is and we can just log it in.<br>8:00 It's blank. There's nothing there. But if we do a one, ah, we have that mistake. Run it. We have, oh, the number Explore number formatting options in Google Sheets for clearer data presentation. Opens in new tab .<br>8:08 Perfect. So our mistake was just in that range Learn about ranges in Google Sheets and how to manipulate them effectively. Opens in new tab . This particular logger kind of thing is available to us, and we can add anything we want.<br>8:17 We can add a little string Explore string manipulation techniques in Google Sheets for better data handling. Opens in new tab here and say data Understand data types and how to manage them in Google Sheets. Opens in new tab from a one. And then the plus sign.

Now when we let's save it first and run it, it will show up in our log data Understand data types and how to manage them in Google Sheets. Opens in new tab from a one and it'll add concatenate Learn how to concatenate strings in Google Sheets for combined data presentation. Opens in new tab or combine Discover how to merge cells in Google Sheets for a cleaner layout. Opens in new tab that string Explore string manipulation techniques in Google Sheets for better data handling. Opens in new tab to the answer of data Understand data types and how to manage them in Google Sheets. Opens in new tab to get value.<br>8:40 So in this video, we coded up a little gathering of data Understand data types and how to manage them in Google Sheets. Opens in new tab . We're inserting it into, we're inserting a new row into a new sheet.<br>8:50 And we're gathering all this data Understand data types and how to manage them in Google Sheets. Opens in new tab in every time we run this script. But how do we run this script every day without our coming here and running this script?<br>9:00 I'm gonna show you that in the next video.</div>