0

I want to import a graphical evaluation (diagram) into a new file using a macro. So the evaluation should not be inserted on a new sheet in the associated file, but a completely new file should be created, in which the graphical evaluation (in the form of a combination diagram) is then copied. The file should be either a Google Sheets or an Excel file. The combination diagram already exists and is located in a Google sheet, but it should be copied into a new file automatically with the help of a macro and the corresponding button. The code below unfortunately only inserts an empty sheet. Where is my error? The chart will depend on the data in the new Spreadsheet, so I need to have the data in the new spreadsheet using importrange. How can I modify the data range with addRange function. The code below unfortunately does not work. Like this an empty chart is inserted. Error Exception: Service error: Tables (line 7, file "Macros") (insertChart Line)

function Auswertung2() {
  var sheet = SpreadsheetApp.getActive().getSheetByName("Evaluation");
  var newSpreadsheet = SpreadsheetApp.create("new spreadsheet");
  var newSheet = newSpreadsheet.getSheets()[0];
  var chart = sheet.getCharts()[0];
  chart = chart.modify().addRange(sheet.getRange("A1:AX80")).setPosition(7, 7, 0, 0).build();
  newSheet.insertChart(chart); 
};```
greenster10
  • 79
  • 1
  • 9
  • Do you have errors? – Lajos Arpad Nov 18 '19 at 08:28
  • Error Exception: Service error: Tables (line 7, file "Macros") (insertChart Line) – greenster10 Nov 18 '19 at 08:36
  • Hello @greenster10, can you obtain more details of the error thrown in your execution? (View>Stackdriver Logging>Apps Script Dashboard & click on a failed execution). Also, when are you setting the data on your new sheet? You say you are using `=IMPORTRANGE` for that, but are you setting the formula programmatically (there is no hint of that in the code you provided)? Cheers – carlesgg97 Nov 18 '19 at 11:32
  • That is all it says! – greenster10 Nov 18 '19 at 12:12
  • 1
    @greenster10 you should create a very basic sample sheet and post it here with your input data, desired output, and current output, because right now it looks like you are just using an invalid range or something. – CodeCamper Nov 18 '19 at 15:14

0 Answers0