How To Duplicate a Template For Every Day of the Year
Learn how to efficiently duplicate a template in Google Sheets for every day of the year using Apps Script, ensuring your spreadsheet remains manageable and fast.
So you have a template and you want to create a new tab for every single day of the year. We have this, it's called Sheet 1, we're going to call this Template . And we're going to make sure that we have a template actually created. So this is very interesting, you may do this because if you want to create a new sheet, it has like a thousand rows, 26 columns, and you create one for every day of the year, you're going to end up getting close to the maximum number of cells , which is 10 million And your sheet might run slow, but so you might want to be duplicating the template like this, which only has 12 cells for every single day of the year. And I'm going to show you how to do that very quickly here with Apps Script extensions, Apps Script, and just follow along as we create it.
New date, and this will be the year. So if it's not 2025, choose a different year. Zero comma one. This is the first day of the year. And we're going to create a while loop here, by just typing while and parentheses date dot getFullYear. And we're just going to make sure that the year is 2025, and it'll stop after the date. It becomes not 2025, because what we're going to do inside of this loop is we're going to create the sheet from our template . We're going to copy it, and then we're going to add one to this date. So each time it'll create the sheet, it'll format the name of the sheet to the date, and it'll add one to the date. All right, so we need const sheet name , and our sheet name is going to be a formattedDateUtilities. Hacks You Might Not Know How To Use a 1-Cell Google Sheet Create Tab For Every Day of the Year Big Year - Yearly Planner
formatDate. We're going to take the date that we declared up here. We'll select our time zone in our sheet. You can choose a time zone like GMT plus six, whatever our time zone is. And we'll format it like this. We're going to use three letters of the month and the day of the month. This is where you can format it any way you want. You can put a year here if you want. Year, year, year. But for our purposes, we just want the month and the date. We're going to create a little variable. SS equals just the spreadsheet that we're on now. Get active spreadsheet. And then we're going to call that active spreadsheet. We're going to get sheet by name. We're going to get the template. Now this has to be the same name as the sheet you're copying. And we're going to copy to the exact spreadsheet that we're on.
But after we do that, we're going to set the name as sheet name as we declared up here, this one. And the final thing we need to do is date dot set date. Date. getDate plus one. So we're just adding one to the day, so that as it goes through this loop, it's going to be adding one to the day. Save this. Make sure you hit save or save project up here, and we're going to click run. We're going to have to authorize the very first time we run this. Once it starts running, you can see it copying and setting the day and the name of the sheet here. It just keeps going and adding it all the time. So that's it. You've duplicated that template for every single day of the year. You can set your year here if it's a different year than 2025. And that is it. Can I Automatically Rename a Sheet based on a Date? Email Yourself a Cell from a Google Sheet, Every Day Richard Asks: Copy Template Tab and Rename to Date Every Week Big Year