Members-only tutorial

Watch the video and get the practice sheet with membership.

See membership options

One Million Checkboxes

About this Tutorial

Check out this fun onEdit() counting you can do with checkboxes in a fun sheet with 1 Million Checkboxes.
Anyone can log into google sheets and go here: https://bettersheets.co/checkboxes

Video Transcript

<div>00:01 I saw this tweet and it's a one million checkboxes, it's a website, and when you check off a checkbox Learn how to use checkboxes in Google Sheets for interactive data tracking. Opens in new tab it checks it off for everyone and you can check on or check off, and there's this counter going on here, however many boxes are checked, so when it's checked on it adds one, if it's checked off it doesn't<br>00:18 add it, and I said this could be a Google Sheet.

Well, I want to put my words to the test and actually create this as a Google Sheet.<br>00:27 We're going to make this totally publicly available ah Google Sheet and we're going to count the boxes as they're checked.<br>00:34 So let's do that, let's go sheet.new, create a new sheet, we'll call it one, we'll call it one, one, one million checkboxes and the point is we're going to try to get to ah a million checkboxes checked.<br>00:49 We don't need tables for this. We do want a bunch of columns but we want those columns to be smaller, maybe 40, maybe less.<br>01:00 Resize column Discover how to resize columns for better visibility in your Google Sheets. Opens in new tab to like 20.

That looks like a square. We'll insert checkbox Learn how to use checkboxes in Google Sheets for interactive data tracking. Opens in new tab . We can actually take the entire column Find out how to apply actions to an entire column in Google Sheets. Opens in new tab . Actually, let's take the entire sheet.<br>01:12 Insert checkbox Learn how to use checkboxes in Google Sheets for interactive data tracking. Opens in new tab . I just did command Y and we have right now, it's a thousand rows but I don't think we need a thousand rows.<br>01:21 I think we need like something like 25. So let's delete all these rows down here. Delete rows 26 to 100 and we need more uh to the right.<br>01:33 We do want to make this a little bit bigger.

I think, um, that looks fine but we need do want a row with no checkboxes and we say however many are counted.<br>01:47 So we'll say here we'll format Explore formatting options to enhance your Google Sheets' appearance. Opens in new tab . We'll have these three be merged as well as these. We'll call it checkboxes. Checkboxes checked.<br>02:04 And then we will increase that a little bit more. There we go. And we'll put in a one here however many are checked.<br>02:12 So once we click, anyone clicks here, we want it to be checked off. So let's go to extensions app script Get introduced to Google Apps Script for automating tasks in Sheets. Opens in new tab .<br>02:19 We're going to use an on-premise on-edit function Understand how to use functions to manipulate data in Google Sheets. Opens in new tab for this.

We're going to share Learn how to share your Google Sheets with others for collaboration. Opens in new tab this and make sure that anyone with the link Find out how to allow anyone with the link to access your Google Sheets. Opens in new tab is an editor Discover the role of editors in Google Sheets and how to manage permissions. Opens in new tab because they need to edit this checkboxes.<br>02:34 So they can come in here, check off a checkbox Learn how to use checkboxes in Google Sheets for interactive data tracking. Opens in new tab , and then this on-edit will work. So we'll use on-edit, we use this event, we're going to get the row of the event, so variable row.<br>02:46 Actually we don't even need the row. All we need to know is if the value, new value is true or false.<br>02:53 Uhm, because checkboxes are just a true or false here. So we just need to know if it's marked true.

So new value equals E dot, I think it's new value, we can always look at on-edit, we can always look at on-edit, uh events, uh simple triggers, that's what we want.<br>03:18 Here's the event objects, that's what we're looking for. And we have all of our options here, so this is open, this is change, here's on-edit, uh old value, all we need is new value, it's gonna be value alone.<br>03:34 So it's just gonna be E dot value. So we can look at this actually, logger dot log.

And see what is the new value.<br>03:42 Let's save this, make sure it's saved here, call it one, million checkboxes, save that, and go and click a few of them, and in our executions we should have the on-edit.<br>04:00 Here, and we'll log what the new value is. Might take a moment to log that. Let's a few more. There it is running.<br>04:18 It says completed. Let's refresh. We should have some type of log here. Logger.log new value. Oh, this is supposed to be just value.<br>04:37 I don't know how that got messed up. Okay. Let's do that again. Do some of those checkboxes.

Go back to our executions.<br>04:46 Let's look at the top ones once it loads. So once it loads, it says true. There we go. So if it says false, we don't want to do anything, so if it says true, we do want to do something.<br>05:00 We do also need variable count is equal to spreadsheet Get familiar with the basics of Google Sheets and its functionalities. Opens in new tab app dot get active spreadsheet Learn how to reference the active spreadsheet in your scripts. Opens in new tab dot get sheet by name. We just want sheet one.<br>05:14 Actually, we might want to rename this checkboxes. There we go. We'll name this checkboxes. We want to get range Understand how to work with ranges to manipulate data in Google Sheets. Opens in new tab is A1, get value.<br>05:29 So every time we get uhm we need the count, that's the count here.

We don't actually need it until we need it here.<br>05:39 And now we want if. New value is equal to true. This might need to change to something like true. We'll see if that works.<br>05:51 Variable count is going to be there. We're going to say variable new count equals count plus one. And then we are going to take this same thing here.<br>06:06 Instead of set, get value, we will set value and we'll set the value to new count. Okay. So this should update that count every time we get a true here.<br>06:16 Ah, this true is going to be a little wonky so let's look at it.

Let's see if it's going to update it here.<br>06:24 Does not look like it's happening. So we may need all caps true or we may need the text true. Let's test it a little bit more.<br>06:37 We may need text true. Here, save it and there we go. So there it is. Now the count is coming up.<br>06:50 Let's make it a little bit bigger and let's change it to something like uh like Consolas in this case. So now every time we have a checkbox Learn how to use checkboxes in Google Sheets for interactive data tracking. Opens in new tab checked.<br>07:07 So one checkbox Learn how to use checkboxes in Google Sheets for interactive data tracking. Opens in new tab , even if we uncheck it, it's not adding. There we go.

So now we'll add to the checkboxes every time this sheet, one million checkboxes is checked. I did want to test it with a new account so I just signed into a different account and I can uh edit these and it also counts.<br>07:33 But if I go to an incognito window, This is interesting is because I'm not signed in I still can do the check boxes, but it doesn't seem to be doing the counting.<br>07:43 It's not loading the app script Get introduced to Google Apps Script for automating tasks in Sheets. Opens in new tab .

So that's something very interesting to know about Google Sheets is that when you allow anyone to edit a sheet, the app script Get introduced to Google Apps Script for automating tasks in Sheets. Opens in new tab will not be loaded.<br>07:54 I think this is a safety feature for Google Sheets so that you don't uh have people who are not logged in.<br>08:00 Logged in, loading possibly a bad kind of app script Get introduced to Google Apps Script for automating tasks in Sheets. Opens in new tab . So, this is very interesting. So you need to sign in as a logged in user and then it will load the app script Get introduced to Google Apps Script for automating tasks in Sheets. Opens in new tab and then it will load this on edit.<br>08:16 So you can actually add to the count.

Before I make this public, I did realize that the million checkboxes website has a million checkboxes.<br>08:26 It's not trying to count to a million. So yeah, we will need ah our, ah what is this, seventy two more rows, okay, two more rows and now nine hundred and ninety rows.<br>08:42 Oop, we added too many. So we're gonna have a thousand rows, a thousand and one rows, but that's a thousand rows of checkboxes and we're going to try to create a thousand in columns, so insert 52.<br>09:00 Columns, so this is 52, we want 48 more. Insert 48. So now this is a hundred, so insert.

So what we want to do is select Explore the SELECT clause in Google Sheets Query for data retrieval. Opens in new tab the columns, insert 100 columns to the right, we're gonna do that now, that's once, twice, three times, four times, five times, six times, seven times, eight times.<br>09:31 So now, let's see how many columns we have. If I select all Learn how to select all data in your Google Sheets for bulk actions. Opens in new tab the columns, I need to do it two more times.<br>09:47 So now there's a thousand columns and there's a thousand rows, so that's one million checkboxes.

And you can see these checkboxes are really struggling.<br>10:06 It's gonna have to load all the way to the end here, to the right, in the bottom, or not, in the top right corner.<br>10:12 And then it's probably going to, they're, it's so slow, and it might add number Understand how to format and manipulate numbers in Google Sheets. Opens in new tab here. There, it, it did it very slowly, but it ultimately did add the, uh, number Understand how to format and manipulate numbers in Google Sheets. Opens in new tab there.<br>10:29 Oh, now it's doing it a little bit faster. It's gotta get up to speed. And now you are able to get to this document if you go to bettersheets.co slash checkboxes.<br>10:40 Checkboxes.

You will be redirected directly to this Google Sheet where Discover how to use the WHERE clause in Google Sheets Query for filtering. Opens in new tab if you are logged in to your Google Workspace, you can check a box.<br>10:49 It'll check it for everyone. It'll add to the checkboxes checked, and you can uncheck it as well, which it will not de-de-delete from that number Understand how to format and manipulate numbers in Google Sheets. Opens in new tab .<br>10:59 It'll just add all the times we're trying checking checkboxes. But yeah, here's a million checkboxes in a single sheet, and it is going pretty slow.<br>11:08 Enjoy.</div>