Learn more about Google Apps Script – Free coding lesson – Source Code included
Apps Script Fun Coding Exercises 2
Sending Email Reminders
Send Google Form Confirmations
Generate Unique ID values
Deleting Specific Rows
Sort Sheet Data
Sending Email Reminders
Create a script that sends an email reminder to yourself every day at a specific time.
function sendEmailReminder() {
var emailAddress = “yourEmailAddress”;
var subject = “Daily Reminder”;
var message = “Don’t forget to complete your daily tasks!”;
MailApp.sendEmail(emailAddress, subject, message);
}
function scheduleEmailReminder() {
ScriptApp.newTrigger(“sendEmailReminder”)
.timeBased()
.everyDays(1)
.atHour(9)
.create();
}
Send Google Form Confirmations
Create a script that automatically sends an email when a Google Form is submitted.
function sendConfirmationEmail(e) {
var email = e.namedValues[“Email”][0];
var subject = “Thank you for submitting the form!”;
var message = “Thank you for your submission. We will get back to you soon.”;
MailApp.sendEmail(email, subject, message);
}
function createFormTrigger() {
var form = FormApp.getActiveForm();
ScriptApp.newTrigger(“sendConfirmationEmail”)
.forForm(form)
.onFormSubmit()
.create();
}
Generate Unique ID values
Create a script that automatically generates a unique ID for a new row in a Google Sheet.
function generateUniqueId() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(“Sheet1”);
var range = sheet.getRange(sheet.getLastRow(), 1);
var id = Utilities.getUuid();
range.setValue(id);
}
Deleting Specific Rows
Create a script that deletes all the rows in a Google Sheet that have a specific value in a certain column.
function deleteRowsWithValue(value, column) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(“Sheet1”);
var data = sheet.getDataRange().getValues();
var newData = [];
for (var i = 0; i < data.length; i++) {
if (data[i][column – 1] !== value) {
newData.push(data[i]);
}
}
sheet.getDataRange().clearContent();
sheet.getRange(1, 1, newData.length, newData[0].length).setValues(newData);
}
Sort Sheet Data
Create a script that automatically sorts a Google Sheet based on the values in a specific column.
function sortSheet() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(“Sheet1”);
var range = sheet.getRange(2, 1, sheet.getLastRow() – 1, sheet.getLastColumn());
range.sort({ column: 2, ascending: true });
}
Note: These are just basic examples of what you can do with Google Apps Script. You can modify these scripts and build upon them to make more complex and useful applications.
#GoogleAppsScript #GAS #AppsScript #GoogleScript #GoogleSheets #GoogleDocs #GoogleForms #GoogleSlides #GoogleWorkspace #GSuite #GSuiteEdu #GoogleEdu #onlinecourses #elearning #distancelearning #onlinetraining #learningonline #onlineeducation #MOOCs #virtuallearning #edtech #educationtechnology #learningsolutions #traininganddevelopment #professionaldevelopment