Posts

Showing posts from July, 2021

Sort by Random - How to Randomize the Order of Rows in Google Sheets

Image
You have a workbook in Google Sheets that contains multiple rows of data and you are required to sort the list in a random order. For instance, your sheet may contain the names of your team members and you need to reshuffle the list before assigning tasks to each of the members randomly. Or your Google Sheet may have the email addresses of people who participated in a giveaway and you need to pick any three random entries in an unbiased manner for the prize. There are multiple ways to randomize the data rows in Google Sheet. You can either use the built-in SORT function of Google Sheets or create a menu-based function that lets you randomize data with a click. Demo - Make a copy of this Google Sheet to try random sort with your own data in sheets. Sort Google Sheets in Random Order Open your Google Sheet that contains the list of data and create a new sheet . Paste the following formula in A1 cell of this empty sheet. = SORT ( Customers ! A2 : D50 , RANDARRAY ( ROWS ( Cus...

Exceeded maximum execution time Exception in Google Apps Script

Google Apps Script is a serverless environment that makes it easy for you to work with Gmail, Google Drive and other services that are part of the Google Workspace platform. When you run any code inside the Google Apps Script IDE, in simple English, it spins up a new server with the required environment that are necessary to run your application. This server is allotted a hard timeout limit and the App Script environment will halt the execution of the function if it exceeds the maximum execution time. Exceeded maximum execution time The maximum execution time varies based on the type of your Google Account. If you are running your Apps Script code inside a Gmail account, your functions can run for 6 minutes before it will be terminated. For Google Workspace accounts, because you are paying a monthly fee to Google per user, the timeout limit is more generous at 30 minutes. If your Apps Script function / trigger exceeds the maximum timeout limit, the script will throw an exception ...

How to Replace Accented Characters (diacritics) with English letters in Google Sheets

Image
The REMOVE_ACCENTED function for Google Sheets will replace all accented characters in the referenced cell, like the letters è, õ, ā, ĝ and so on with their normal Latin equivalents. To get started, make a copy of the Google Sheet , go to the Tools menu, choose Script Editor and copy the entire code to your clipboard. Now open your own Google Sheet and paste the same code inside the Script editor of your sheet. Save and you should be able to use the REMOVE_ACCENTED function in your own sheets. Input String Output string A História de Malú e João Miguel A Historia de Malu e Joao Miguel Símbolo de su unidad y permanencia Simbolo de su unidad y permanencia Tomás Gutiérrez Alea Tomas Gutierrez Alea Miguel Ángel Félix Gallardo Miguel Angel Felix Gallardo Internally, this function uses the deburr function of the popular lodash library that converts Latin-1 Supplement and Latin Extended-A letters to basic Latin letters and also removes any combining diacriti...

How to Find and Replace Text in Google Docs with RegEx Search Patterns

It is easy to search and replace text in Google Documents with the DocumentApp service of Google Apps Script. You can use use findText method with simple regular expressions to find text elements in the document that match a pattern and replace them with the specified text. Here’s a simple code sample that replaces the first occurrence of the “GSuite” with “Google Workspace” in the active Google Document. const searchAndReplaceInGoogleDocs = ( ) => { const searchText = "GSuite" ; const replaceText = "Google Workspace" ; const document = DocumentApp . getActiveDocument ( ) ; const documentBody = document . getBody ( ) ; const searchResult = documentBody . findText ( searchText ) ; if ( searchResult !== null ) { const startIndex = searchResult . getStartOffset ( ) ; const endIndex = searchResult . getEndOffsetInclusive ( ) ; const textElement = searchResult . getElement ( ) . asText ( ) ; textEl...