Macros In Google Sheet

  • We can run macros in Google Sheets, as long as they’re written in Google Apps Script, a JavaScript-based language built into Google Apps. 
  • It’s a cloud based scripting language for extending the functionality of Google Apps and building lightweight web-based applications.

Begin by creating a new Google Sheet. Then, click the menu Tools > Script editor... to open a new tab with the code editor window.


This will open a new tab in our browser, which is the Google Apps Script editor window.


By default, it’ll open with a single Google Script file (code.gs) and a default code block, myFunction() :
function myFunction() {
}

Write sample code.


Next hit the run button (the black triangle), which prompts us to authorize the app to run.

Example : By using this we can automatically send email ( with Gmail ) from Google spreadsheet, or automatically add new people from a spreadsheet to Google Contacts etc.