I am trying to copy a tab from a spreadsheet and paste it in multiple spreadsheets at the same time. The spreadsheets are all in folders on google drive, and there are two levels of folders, parent folders and their child folders, inside the child folders are the files. The code is the following:
function sendtomultiple(){
const source = SpreadsheetApp.getActiveSpreadsheet();
const source_id = source.getId();
const fechas = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('fechas2');
const folderIds = ['folder Ids']; // Add your parent folder ids
folderIds.forEach(folderId => {
const parentFolder = DriveApp.getFolderById(folderId);
const subfoldersIter = parentFolder.getFolders();
const folders = [parentFolder];
while (subfoldersIter.hasNext()) {
folders.push(subfoldersIter.next());
}
folders.forEach(folder => {
const sheetDestino = folder.getFilesByType(MimeType.GOOGLE_SHEETS);
while (sheetDestino.hasNext()) {
let target_file = sheetDestino.next();
let target_id = target_file.getId();
let target_ss = SpreadsheetApp.openById(target_id);
if(target_id!=source_id){
fechas.copyTo(target_ss).setName(fechas.getName());
}
}
}
)}
)}
It's running smoothly but it's not pasting the tab in the spreadsheets. The tab has formulas in it and I would like those formulas to be pasted, not the values. Does anybody know why it's not working? Any help is appreciated! :)