Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

266
Views
How do I get my code on google sheets to cover multiple tabs?

I have a code that runs on my google sheets every time someone fills out a form online which pushes info into my CRM Software. It pulls the info in great off of the main tab; but how can I get the script to run for multiple tabs on the same spreadsheet? I tried a couple solutions but couldn't figure it out. this is the current code

var sheet = SpreadsheetApp.getActiveSheet();

var scriptProperties = PropertiesService.getScriptProperties();   
var lastRange = scriptProperties.getProperty("last_range");

//Logger.log("Debug:" + lastRange);

if (!lastRange) {
  var lastRow = sheet.getDataRange().getLastRow() + 1;
  scriptProperties.setProperty("last_range", "A" + lastRow);
  lastRange = scriptProperties.getProperty("last_range");
}

var range = sheet.getRange(lastRange);
var totalRange = sheet.getDataRange();
var isBlank = range.isBlank();
var isGreater = false;
 
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

You are currently using:

var sheet = SpreadsheetApp.getActiveSheet();

Where you should be using:

var sheet = SpreadsheetApp.getActive().getSheetByName(sheetName);

You haven't specified which tabs (sheets) you have, but it should be a simple case of dropping in the appropriate sheet name in the function above.

See https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet#getSheetByName(String)

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!