Tuesday 31 August 2021

Find and replace in a Google Sheet - ReplaceAllWith

This blog post is a slight adaptation of the one here for Find and replace on a whole Google Sheet. This time we are focussing upon the fastest way to change all of the text values without highlighting changed cells. In effect we have deleted a chunk of code and replaced it with one single line:


So whilst we can no longer target a specific cell for any formatting changes, this method saves us time by not performing any more loops, and so may be your chosen method for speed.

Tuesday 24 August 2021

Bulk create Google Drive Folders and add Files

The following Google Apps Script tool was developed to bulk create Google Drive folders with optional files copied in to each one, all from data within a Google Sheet. There is also the option to add specific 'edit' permissions to the newly create Drive folders of which the files would automatically inherit this access level.

The tool is an expansion of the 'Bulk create Google Drive folders 2.0' blog post here, so you may wish to read and watch the video on there first. Also note I have version 2.0 of this tool available now.

Bulk create Google Drive folders and add files, from a Sheet of data
Bulk create Google Drive folders and add files, from a Sheet of data

Key Functionality
  • Complete the necessary information in the Config sheet before proceeding. Then use the Create folders option from the Admin menu at the top of the Google Sheet.
  • Adding permissions is optional - use the Config sheet to change the dropdown as required. If you select 'No' then the usual Google Drive inheritance will occur based on the parent Google Drive folder.
  • You can add multiple File IDs into the relevant cell and they can be different for each row. Leaving this cell blank/empty means no files will attempt to be copied into the new folder.
  • The original filename will be updated during the copy to append the folder name to the end of it, in order to prevent creating a large number of files with identical names.
  • There is a Log sheet to help troubleshoot any errors which may occur when running the tool.

Tuesday 17 August 2021

Send data to a Google Form via Apps Script

The following Google Apps Script is designed to submit specific data to a Google Form, by creating a prefilled URL. The reason for this was I needed some way of sending data from a number of individual Google Sheets (that I did not own) to one central location, but crucially it needed to be anonymised.

Sending the data directly to a Google Sheet includes version history both in the file and cell meaning it was not truly anonymous. Whereas sending the data through a Google Form and then on to the Response Sheet did strip away anything identifiable.

The logic behind this code is to create a prefilled URL which contains answers to each of the Forms questions. Use the previous webpage link to learn how to create such a URL first so that you understand each question on a Form has a unique value.

Questions from a Google Form can be answered in advanced via a prefilled URL.
Screenshot of Google Form questions

Tuesday 10 August 2021

Search Google Drive files and extract row data

The following Google Apps Script is designed to search the content of files on Google Drive which includes the given search word(s). Once it has collated these files it will then go into each one, search for the row of data that matches our search word(s) and extract that into a collective Google Sheet.

The information collected from the initial search to collate the files includes:

  • The filename,
  • The file ID,
  • A direct/clickable link to the file,
  • The type of file - this tool is restricted to Google Sheet.

The information collected from the second part of the tool includes:

  • A direct/clickable link to the file,
  • The Header row from the file,
  • The row of data from the file.
Search and extract the content of Google Drive files
Search and extract the content of Google Drive files

Tuesday 3 August 2021

Check the domain of an email address by regex

The following Google Apps Script is designed to use a regular expression (regex) to confirm if an email address domain matches one we specify eg: @hotmail.co.uk, @gmail.com, @outlook.com

I developed the code so I could screen email addresses to make sure they only came from within the institution - otherwise it would have broken the tool I was developing for creating Zoom meetings. The email addresses in this example are all stored in one cell in a Google Sheet and are separated via a comma and a single space.

Email addresses in a Google Sheet with different domains can be filtered.
Screenshot of email addresses in a Google Sheet cell