Is there a way to add a jQuery string inside of a Google Sheet?

Viewed 28

So imagine I have a string,

var greet = "hi"

And I want to put it in the next available row in a Google Sheet, how can I do that?

1 Answers

This can easily be done in Google Apps Script. Google Apps Script is a cloud-based JavaScript platform that lets you integrate with and automate tasks across Google products.

To go to Google Apps Script

  1. Go to Extensions -> Apps Script.
  2. Remove the code in Code.gs file
  3. Paste the code below.
  4. Run and authorize

Code:

function myFunction() {
//this code will insert hi to the next available row of active sheet
  var sheet = SpreadsheetApp.getActiveSheet()
  var greet = "hi"
  sheet.appendRow([greet])
}

Example:

enter image description here

Output:

enter image description here

Note: If Google Apps Script is not an option for you, you have to use the Google Sheets API

References:

Related