Click Checkbox to Copy to Tab in Google Sheets

Learn how to use Google Sheets and Apps Script to copy data from one tab to another when a checkbox is checked. This tutorial covers the necessary code and logic to automate the process seamlessly.

We have some data here on the data tab. When we click the checkbox , we want to copy to another tab, so let's do that with extensions app script . Over in extensions app script . We're gonna change this function to on edit, and we're gonna put a variable here. This could be any word like event, word, whatever. We're gonna use the letter E as the. Variable and this gives us some really cool data . Variable row equals E range. Do get row, variable call or short for column equals E range. Do get column, full column. So that tells us where we are. We need to know the sheet as well, that we're on spreadsheet app. Get active spreadsheet, get active sheet. That's the tab. Get name.

And we need to know what value is happening. So if we edit some kind of text, like real one, the value there is real one. When we go to this, a column with this checkbox , it's just a visual representation of true or false. So checking a box true changes it from text , from false to true. We need to know that because we need to know the value here. Value equals. E value. Now, based on all this data we have, we're only gonna change or copy the data in one instance where the row is greater than one, meaning it's not the header row M percent for, and the column is equal to two equal sign, one M percent sheet is equal to data .

That's the name of the tab and another double M percent, and our value is equal to true. And that needs to be two equal signs. Now, based on all of those circumstances or criteria , we want to execute something which is we want to copy that road of data to the other sheet. Our other sheet is just called more data . So we need to know something about more data . We need to know the last row equals spreadsheet , app dot get active spreadsheet , get sheet by name. More data do get last row, and then we're gonna execute something, meaning this more data sheet, we actually need also as a variable, more data. So variable more data equals this. So on that more data sheet. We're gonna get a range, which is last row plus one, whatever's the last row.

Add one to it, comma one, which is only one column. The first column actually, we wanna set it on the second column, and we're gonna set the size one row, three columns, because that's the size of our data . You can change that to whatever your thing is needed to. Now we're gonna get that range and we're going to set the values . What are we gonna set the values of? Well, we're gonna have our data sheet, so that's gonna be spreadsheet app that get active, spreadsheet dot, get sheet by name equals data . So we go in, data do get range. We know what row we're in. We're gonna go to the second column and we're gonna do the exact same size, one

row, three columns, and that's our data . But actually we need to do get values . So the data range is here and we need to do dot get values to get those values copied. So let's save this all. We don't have to do anything else. We don't have to set up any triggers. We have a simple trigger called on edit here, and let's test this out. Real actual data . Let's copy it over to more data . And there it is. Real actual data. More actual data. There's more actual data. Some actual data. Almost, did we not, did we get some error here? Oh, it's still running, so sometimes we might have done it a little too fast. There it is. Some actual data. Oh, my data. Let's skip. Yes. Real data. Oh my data. And there is, oh, my data.

Now if we uncheck all of these, nothing will happen. Wait, we also just checked, yes, real data , but uncheck, nothing should happen. Now let's check some actual data and see some actual data at the bottom. Perfect. So we have done it right. We didn't get any errors. If we did get any errors, they would be over here in executions in your app script . If you want to copy this app script , I'll put it in the description below. Okay. You are watching better sheets here on YouTube. Make sure you check out this video or this video and subscribe right now to get more tips, tricks, how tos, get more out of your Google sheets than you ever have before. I'm excited to be making a ton more videos here. Ask me questions down in the comments and I will answer them in future videos.

But for right now, right here, one of these videos is gonna be your next Google sheet.