Calculate a weighted Average from a range of values

WEIGHTED_AVERAGE  Value Weight 10 0.1 15 0.1 5 1 Result 6.25 Scenario: You want to create a custom Google Sheets formula that calculates the weighted average of values in a specified range, where each value is multiplied by its corresponding weight. Data Table: A B C 1 Value Weight 2 10 0.3 3 15 0.5 … Read more

Calculate average from range above a threshold

AVERAGE_ABOVE_THRESHOLD 7 4 9.333333333 6 10.66666667 15 11.33333333 11 8 In this example, we’ll create a custom formula that calculates the average of a range of numbers, excluding any values that are less than a specified threshold. Scenario: You have a range of numbers in column A and a threshold value in cell B1. You … Read more

Quotas for Google Services

When running apps script try to avoid longer than 5 minutes executions, if you need more processing you should chunk the operation into more manageable pieces. Apps Script services have daily quotas and limitations on some features. If you exceed a quota or limitation, your script throws an exception and execution stops. https://developers.google.com/apps-script/guides/services/quotas Feature Consumer … Read more

How to see all Bound and Standalone Google Apps Script from an account

Google Apps Script is a scripting language that allows you to automate tasks, extend functionality, and customize Google Workspace (formerly known as G Suite) applications such as Google Sheets, Google Docs, Google Slides, and more. It provides a way to write code and create custom scripts that interact with various Google services and APIs. Within … Read more

Hide Columns and Rows using Google Apps Script

Hides one or more consecutive columns starting at the given index. Use 1-index for this method. var ss = SpreadsheetApp.getActiveSpreadsheet();var sheet = ss.getSheets()[0];// Hides the first three columnssheet.hideColumns(1, 3); Here’s an example of how to use sheet.hideColumns in Apps Script to hide specific columns in a Google Sheets spreadsheet: function hideColumnsExample() { // Get the … Read more

Listing contents of paragraphs using Google Apps Script

To use this code: Remember to adjust the index in getChild() based on your specific requirements and the structure of your document.

Apps Script Doc Lists

o add numbered list items to a Google Docs document using Apps Script, you can use the setListId() and setNestingLevel() methods of the ParagraphHeading element. Here’s an example that demonstrates how to add numbered list items: function addNumberedListToDoc() { var doc = DocumentApp.getActiveDocument(); var body = doc.getBody(); // Create a numbered list var listItems = … Read more

Apps Script createEventFromDescription

createEventFromDescription Apps Script from a description. Here’s a code snippet that demonstrates how to achieve that: function createEventFromDescription() { var calendarId = ‘YOUR_CALENDAR_ID’; // Replace with your calendar ID var description = ‘Event Description’; // Replace with the description for your event var calendar = CalendarApp.getCalendarById(calendarId); var event = calendar.createEventFromDescription(description); Logger.log(‘Event created: ‘ + event.getTitle()); … Read more

Count the number of occurrences of a given substring in a string

Count the number of occurrences of a given substring in a string function COUNT_SUBSTR(str,sbStr){  let count = 0;  let pos = str.indexOf(sbStr);  while (pos !== -1){    count++;    pos = str.indexOf(sbStr,pos+1);  }  return count; } The provided code defines a function called COUNT_SUBSTR that takes two parameters: str and sbStr. The purpose of this function is … Read more

Top 10 Tips for using Google Apps Script

Here are the top 10 tips for using Google Apps Script: Remember, practice and experimentation are key to mastering Google Apps Script. Don’t be afraid to try new things and build upon your knowledge as you go along. Happy scripting!