Google Sheet : how to split a list into different tabs

685 views
Skip to first unread message

Loveday Lemon

unread,
Jun 28, 2022, 1:13:33 PM6/28/22
to Google Apps Script Community
Hi all, I have a sheet with 12 races listed, each race has 6 to 10 dogs. I need a script that will create separate tabs : Race 1, Race 2...based on the race number indicated in column A. I am a complete novice to scripts and am feeling a bit overwhelmed. If anyone knows of a script example that does something similar, and that I could try to adapt, instead of starting from scratch, I'd be very grateful.

Jonathan Butler

unread,
Jun 28, 2022, 4:18:24 PM6/28/22
to google-apps-sc...@googlegroups.com
This could probably be done manually in the time it takes to write a script. Also, the sheet isn't in a format in which there would be a script readily available. There might be someone on here willing to do it though.

On Tue, Jun 28, 2022 at 12:13 PM Loveday Lemon <bakerst...@gmail.com> wrote:
Hi all, I have a sheet with 12 races listed, each race has 6 to 10 dogs. I need a script that will create separate tabs : Race 1, Race 2...based on the race number indicated in column A. I am a complete novice to scripts and am feeling a bit overwhelmed. If anyone knows of a script example that does something similar, and that I could try to adapt, instead of starting from scratch, I'd be very grateful.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/273e431c-ea0a-481f-b9d1-7d029b67bcd0n%40googlegroups.com.

Loveday Lemon

unread,
Jun 28, 2022, 5:37:23 PM6/28/22
to Google Apps Script Community
The thing is, this will have to be done twice a week, so I was hoping a script could do it. If someone has a link to a sheet with a script that does something similar it would give me a basis to understand how these things work. If not, I'll do it manually. Thanks. 

CBMServices Web

unread,
Jun 28, 2022, 6:59:31 PM6/28/22
to google-apps-sc...@googlegroups.com
Hi, can you show us how you would like the race sheets to look like? Perhaps you can do one of them manually just to show us.

Also, just wondering why you would need to have each race in a separate sheet. Is it just for printing results or for further manipulation? Or..


Jonathan Butler

unread,
Jun 28, 2022, 7:39:11 PM6/28/22
to google-apps-sc...@googlegroups.com
I couldn't find a similar script. However, I did write what I believe you are looking for. It's in the sheet and should be runnable from the "Sheet Functions" menu item.

Loveday Lemon

unread,
Jun 30, 2022, 9:19:47 AM6/30/22
to Google Apps Script Community
Thanks a lot guys! I will try it today and let you know. Having one sheet per race is for convenience reasons, as each race will have a different number of dogs, it's easier when analyzing a race to concentrate on one sheet only. 

Loveday Lemon

unread,
Jul 3, 2022, 9:24:06 AM7/3/22
to Google Apps Script Community
Thank you so much  butlerjon...@gmail.com! Your script does exactly what I was looking for! Next, I would like to learn how to do a script that will add to each of the race tabs an additional column with a formula that will get the link to that individual dog G sheet. Using google search, I have found a script that lists the contents of the folder that has all the dog sheets, and managed to write a formula that pulls the relevant dog G sheet URL. Next I need to find out how to get that formula automatically added to each race sheet (I have included an example in Race 1).  I'll keep googling it but if you had an example I'd be grateful. I'd like to learn how to write scripts by myself during my summer holiday coming up soon, so if you have recommendations for good websites to start, that would be great. I use the basic functions of G sheet for work (I'm a chemical engineer) but learning how to script will be a big step for me.

On Wednesday, 29 June 2022 at 1:39:11 am UTC+2 butlerjon...@gmail.com wrote:

Jonathan Butler

unread,
Jul 7, 2022, 9:15:40 AM7/7/22
to google-apps-sc...@googlegroups.com
No problem, and welcome to Google Apps Scripting. Some things you should know first. Google apps script is a series of libraries built on top of Javascript the programming language. So when googling around for certain concepts, try adding Javascript if Google Apps Script gives you no hits. The second, given that whenever a sheet is created it is created with 26 columns, and I doubt that any of the race information will start off with 26 columns you can append data to each array that is created.

What does that actually mean? In the code below sheetData is a 2D array similar to a table or a spreadsheet. You are going to need to understand javascript loops if you want to build scripts like this. If you add the formula you want to the top right , and add an extra "column" to all of the arrays below that array in the 2D array (you will get an error if you don't) it will add one formula where you desire. I edited the code on the sheet to include a loop that does so.




Reply all
Reply to author
Forward
0 new messages