I'm very new to writing code, and I need some help. I'm working on google sheets. In the code below, I was trying to call the Merge() function within the copyAllInRange() function. I saw many examples, but I'm a bit confused about how to do it. Both functions work well; I don't know how to call one function into another.
The objective is to run copyAllInRange(); and at the end of the function call the Merge() function to run.
function Merge(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('PDF_TEMP');
var Range_Logo = sheet.getRange('C11:D16').merge();
var Range_Bottom = sheet.getRange('C50:J52').merge();
Range_Bottom.setHorizontalAlignment("center").setVerticalAlignment("middle");
Range_Logo.setHorizontalAlignment("center").setVerticalAlignment("middle");
}
function copyAllInRange(){
var SS = SpreadsheetApp.getActiveSpreadsheet();
var NS = SS.getSheetByName("PDF_TEMP");
if (NS != null) {
SS.deleteSheet(NS);}
NS = SS.insertSheet();
NS.setName("PDF_TEMP");
var Sheet = SS.getSheetByName("Factura");
var TR = Sheet.getRange("C3:N59");
var PR = NS.getRange("A1:L55");
var columnWidths = SpreadsheetApp.CopyPasteType.PASTE_COLUMN_WIDTHS
TR.copyTo(PR);
TR.copyTo(PR,columnWidths,false);
}
Both are in the same script file; both work independently.



