need some help here. I have a master google sheet that has several tabs. Most of them contains private information, so i have to import a tab(sourcetab) that is for public view to another spreadsheet so that i can share it on google site.
I have tried importrange but it only copy the values to a destination tab of another spreadsheet.
Problem 1: The source tab has several links, images and formatting that i would need it on the destination. Problem 2: My management will update the master source tab and would like the destination to be updated automatically as well, with all formatting and links attached. I understand that google app script might be able to help.
Therefore, will need help to advise on how to duplicate the source tab into a destination tab and get it updated when there is changes in the master tab.
[1][Tried copytab but it only creates a new tab in the source and does not update automatically when there is any editing in the master tab]
function copyTab() {
var ss, sourceSheet, sourceData, sourceDataRange, newSheetTab;
ss = SpreadsheetApp.getActiveSpreadsheet();//Get active spreadsheet
sourceSheet = ss.getSheetByName("Sample: Restriction Updates");//Get the source sheet tab
newSheetTab = ss.insertSheet("newsheet");//Create a new sheet tab
sourceDataRange = sourceSheet.getDataRange();
sourceDataRange.copyTo(newSheetTab.getRange(1, 1));//Copies the data from a range of
//cells to another range of cells. By default both the values and formatting are copied
}
[2][Tried to create into the destination but failed]
function myFunction() {
var source = SpreadsheetApp.openById('sourceID');
var sourceSheet = source.getSheetByName('Sample: Restriction Updates');
var sourceRange = sourceSheet.getDataRange();
var sourceValues = sourceRange.getValues();
var tempSheet = source.getSheetByName('temp');
var tempRange = tempSheet.getRange('A1');
var destinationsheet = SpreadsheetApp.openById('DestinationID');
var destination = source.getSheetByName('Test');
sourceRange.copyTo(tempRange); // paste all formats?, broken references
tempRange.offset(0, 0, sourceValues.length, sourceValues[0].length)
.setValues(sourceValues); // paste all values (over broken refs)
tempSheet.copyTo(destination); // now copy temp sheet to another ss
}