Create Custom Functions on Google Sheets

In this post, I demonstrate how to Create Custom Functions on Google Sheets using Google Apps Script. In the How to Video, I cover 4 unique examples.

How to Video:

Video Notes:

  • Legacy Apps Script Editor Used in Video
  • Apps Script (Script Editor) is now located under tab ‘Extensions’ instead of ‘Tools’ on Google Sheets

Code in Video:

function DOUBLE(input) {
  
  return input * 2;
  
}

function DOUBLE_RANGE(input) {
  
  var total = 0;
  
  for(y = 0; y < input.length; y++)
  {
  
    for(i = 0; i < input[y].length; i++)
    {
      total = total + (Number(input[y][i]) * 2);
    }
  
  }
  
  return total;
  
}

function TRANSLATE(input)
{
  var languageOutput = LanguageApp.translate(input, 'en', 'es'); 
  return languageOutput;

}

function API_CALL(input)
{

  URL_STRING = "https://api.agify.io?name="+input+"&country_id=US";

  var response = UrlFetchApp.fetch(URL_STRING);
  var json = response.getContentText();
  var data = JSON.parse(json);
  
  return data.age;
  
}

Related Posts

IF Function Google Sheets How to use IF Function on Google Sheets - In this post, I demonstrate how to use the IF function on Google Sheets. In the How to Video, I cover 4 useful examples.
VLOOKUP Function Google Sheets How to use VLOOKUP Function on Google Sheets - In this post, I demonstrate how to use the VLOOKUP function on Google Sheets. In the How to Video, I cover 3 useful examples.