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

145
Views
Define multiple get Ranges and Sheet Names with javascript

I am using below script to pull date from all spreadsheets in a folder. It is strong and working.

now i would like to expand this script to define multiple different sheet names instead of one. that is because we have the same file in 3 different langueses, now when it is running and there is a file from an other langues it cannot find the sheet(name) so the script gives the error that GetRange is null. The data is the same, So Ill go through the files looking for

The sheets: "Gegevenskaart" || "DataCard" || "Datenkarte"

The Same for Range. in this specified Sheet I have 6 different ranges. they are all the same size and all have the same kind of data but there are rows that I dont want to use. (20 rows data, 25 empty rows in between)

The ranges to get data from are : [A15:BC34 ,A63:BC82 ,A11:BC130, A159:BC178 ,A207:BC226 ,A255:BC274, A300:3BC319] (also these data rows have a string in colomn A while the other rows dont have a string)

    function CombineDataToMasterFile() {                                                                    

  var folder = DriveApp.getFolderById("1234567890234567891234567");
  var filesIterator = folder.getFiles();
  var file;
  var fileType;
  var ssID;
  var combinedData = [];
  var data;

  while(filesIterator.hasNext()){
    file = filesIterator.next();
    fileType = file.getMimeType();
    if(fileType === "application/vnd.google-apps.spreadsheet"){
      ssID = file.getId();
      data = getDataFromSpreadsheet(ssID);
      data = data.map(function(r){return r.concat([file.getName()]); });
      combinedData = combinedData.concat(data);
    }
  }

  var ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Datatest");
  ws.getRange("A2:BC").clearContent();
  ws.getRange(2, 1, combinedData.length, combinedData[0].length).setValues(combinedData);
} 

function getDataFromSpreadsheet(ssID){

  var ss =  SpreadsheetApp.openById(ssID);
  var ws = ss.getSheetByName("Blad1");
  var data = ws.getRange("A15:BC34").getValues();
  return data;
about 4 years ago · Juan Pablo Isaza
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!