I have a script that import range in files from folder. The promblem is that in column A i have 3000 not emty cell, but i need import all range but filter that have not empty cell in column B
function Import_() {
var arr = [];
var files = DriveApp.getFolderById("17Ux9i0mK_RTuLbrjFrZDGoNl3AkcEdRS").getFiles();
var ss = SpreadsheetApp.getActiveSpreadsheet()
var copySheet = ss.getSheetByName("Cell")
copySheet.getRange('A2:M').clear();
while (files.hasNext()) {
var file = files.next();
var ss1 = SpreadsheetApp.openById(file.getId())
var sheets = ss1.getSheetByName("Cell")
var sheetsRange = sheets.getDataRange()
var sheetsValues = sheetsRange.getValues()
arr = arr.concat(sheetsValues.slice(4))
}
copySheet.getRange(2, 1, arr.length, arr[0].length).setValues(arr)
CodePudding user response:
try this:
function Import_() {
var arr = [];
var files = DriveApp.getFolderById("17Ux9i0mK_RTuLbrjFrZDGoNl3AkcEdRS").getFiles();
var ss = SpreadsheetApp.getActive\()
var sh = ss.getSheetByName("Cell")
sh.getRange('A2:M' sh.getLastRow()).clear();
while (files.hasNext()) {
var file = files.next();
var ss1 = SpreadsheetApp.openById(file.getId())
var s = ss1.getSheetByName("Cell")
var v = s.getDataRange().getValues().filter(r => r[1]).filter(e => e);
arr = arr.concat(v.slice(4))
}
sh.getRange(2, 1, arr.length, arr[0].length).setValues(arr)
}