I was researching how to do what I needed and I found this video and thought it was PERFECT for me.
It shows how to set up a script on a page to import an entire folder, which is exactly what I need. I have 14 sheets that are identical. I need to copy A2:F
from all of them into one sheet. Here is the script:
function getdata() {
var files = DriveApp.getFolderById("0B94fkeHjleasRF9QMDFlcHllRVU").getFiles()
while (files.hasNext()) {
var file = files.next();
var shoot = SpreadsheetApp.openById(file.getId());
var sourcesheet = SpreadsheetApp.getActive().getSheetByName("Sheet1");
var sourcerange = sourcesheet.getRange('A2:F');
var sourcevalues = sourcerange.getValues();
var destsheet = shoot.getSheetByName('Sheet1');
var destrange = destsheet.getRange('A2:F');
destrange.setValues(sourcevalues);
}
}
The problem is: although it worked in the video, I can't seem to get it to work for me. I played with the last line (which where I am getting an error). I managed to get the script to delete all the information I needed to copy. Lol. So obviously I need help. Can anyone see any glaring mistakes in this script?
I have tried importRange
but it hangs up on array formulas. This script seemed perfect, if only I could get it to work.
while
loop. If you want the source data to be the data from the active sheet, and it's always the same range, you should put that outside of the loop. You'd only need to get the source data once. – Alan WellsgetRange()
method. Each takes either a different number of parameters, or a different type of parameter. I'm using a different variation in the code I'm proposing. – Alan Wells