Close Google Form After Certain Number in Cell in Google Sheets
Learn how to close a Google Form after a certain number of guests have been submitted using Google Sheets and Apps Script. This tutorial shows how to dynamically set the limit in a cell and automate the process.
in the previous video I showed you how to close a form after a certain amount of responses so our form is created here and we have two responses so far but in our appscript we say hey however many responses there are if it's over three stop taking responses but what if you wanted to set this number say in a cell and what if it wasn't counting the responses but let's say guess where every single time someone fills in the form they're filling in a number not just the number of responses but the number that's adding up here how do we do this so we need to do a couple of different things we've already set up our appscript and Close Form After Certain Number of Responses How to Send Google Forms Entries Automatically with Apps Script Close Form After Certain Number of Responses Add Formula When Form Submitted
our trigger so we don't need to do that again but I will go over that I think at the end of this video just to make sure that you know how to do that if you haven't seen the other video but let's go to our form and add another question and and say guess and this is going to be a short answer just a number if we refresh the sheet we now have name your name and number of guests so let's say Andrew and we're bringing in three guests submit Fred is bringing in four submit and over here on our sheet we can see the guests are lining up here let's submit another response and it's closed right because it's still based on the response count so let's edit this appscript and we're going to need one Close Form After Certain Number of Responses Close Form After Certain Number of Responses Create New Tab For Each Google Form Submission
extra thing let's get a count here we will say number of guests equals sum and we're just going to sum up this C column so right now it's seven and let's say we want our limit to be 10 if total guests here become more than 10 we don't want any more responses so let's go to our appscript and start editing this so we don't need response count anymore we have actually need guest count we're going to get the guest count not from the form responses but actually from the spreadsheet itself so we're going to go to spreadsheet app. getactive spreadsheet which is the total workbook that we're working in G sheeet by name and over here let's make sure we Close Form After Certain Number of Responses Manage Your Wedding Guest List with these 5 Advanced Google Sheets Formulas Add Formula When Form Submitted
have the correct sheet count is what we need count get range let's make sure we get the correct range we're going to go to count we're going to get B1 B1 and we need a get value now we need to make sure that that guess count if that guess count is greater than this number actually we can probably even do greater than or equal to is probably better so let's get guest limit and again we're going to do the same thing we did with guest count but we're just going to go to a different range let's copy paste that but not B1 we're looking at B2 here so let's change B1 here to B2 so again we're just going to go to the spreadsheet app using the function built in here getting the entire workbook getting the sheet count called count 3 Ways to Count in Google Sheets How to Count Between 1 and 16 in Google Sheets Get Values from Sheet for Custom Function in Apps Script
getting the range B2 and getting the value within that cell now if the guest count is greater than or equal to the guest Limit Oh we need to make sure this is guest limit here save that then we will turn off our form so let's go back and turn on our form we are now turned on if I refresh this we can respond to this form so let's say Linda is bringing in five people click submit and we see here 12 guests over the limit and let's see if we can submit another response this form is no longer accepting responses so it has closed correctly fantastic that's it that's how to get a number from your sheet into appscript Form Automations: Close Multiple Forms When Over Limit Close Form After Certain Number of Responses Get Values from Sheet for Custom Function in Apps Script
and check it when we're trying to close that form now just to refresh if you haven't watched the original video we need like three things we need the form we need this function check form and we need to go over to triggers and add a trigger we've already created this trigger it's here I'm going to go and delete it here for now but I can easily add it I'm going to show you how to add trigger right now click add trigger we going to choose which function if there's only one function it's the only one here if you have other functions you have to select it from spreadsheet is the Event Source and event type is on form submit so every time a form is submitted this function is going to be triggered and that's the whole process here thanks for watching Form Automations: Close Multiple Forms When Over Limit What Can You Automate in Google Sheets? Every single trigger available to Google Sheet users Google Form Automation Basics with Google Sheets and Apps Script
and I hope you enjoyed this and I hope you are subscribed to better cheets here on YouTube if you're not go ahead and do it now because we got tons more videos coming out and making your spreadsheets way better Better Sheets Videos Checklist 80 Years In 1 Spreadsheet YOU CAN DO BETTER