Hi
This is the first time I have written a script for office365 and it dont appear to run as may be too long.
Is anyone able to have a look and advise why?
This is the first time I have written a script for office365 and it dont appear to run as may be too long.
Is anyone able to have a look and advise why?
VBA Code:
function main(workbook: ExcelScript.Workbook) {
let sheet2 = workbook.getWorksheet("Sheet2");
let selectedSheet = workbook.getActiveWorksheet();
// Paste to range I7 on sheet2 from range AA23 on selectedSheet
sheet2.getRange("I7").copyFrom(selectedSheet.getRange("AA23"), ExcelScript.RangeCopyType.values, false, false);
// Paste to range I9 on sheet2 from range AA24:AA26 on selectedSheet
sheet2.getRange("I9").copyFrom(selectedSheet.getRange("AA24:AA26"), ExcelScript.RangeCopyType.values, false, false);
// Paste to range I15 on sheet2 from range AA27:AA28 on selectedSheet
sheet2.getRange("I15").copyFrom(selectedSheet.getRange("AA27:AA28"), ExcelScript.RangeCopyType.values, false, false);
// Paste to range I18 on sheet2 from range AA29:AA30 on selectedSheet
sheet2.getRange("I18").copyFrom(selectedSheet.getRange("AA29:AA30"), ExcelScript.RangeCopyType.values, false, false);
// Paste to range I21 on sheet2 from range AA31 on selectedSheet
sheet2.getRange("I21").copyFrom(selectedSheet.getRange("AA31"), ExcelScript.RangeCopyType.values, false, false);
// Paste to range I24 on sheet2 from range AA32:AA34 on selectedSheet
sheet2.getRange("I24").copyFrom(selectedSheet.getRange("AA32:AA34"), ExcelScript.RangeCopyType.values, false, false);
// Paste to range J7 on sheet2 from range C7:C27 on sheet2
sheet2.getRange("J7").copyFrom(sheet2.getRange("C7:C27"), ExcelScript.RangeCopyType.values, false, false);
// Set range K7 on sheet2
sheet2.getRange("K7").setFormulaLocal("=sum(I7:J7)");
// Paste to range I10 on sheet2 from range I9:I11 on sheet2
sheet2.getRange("I9:I11").moveTo(sheet2.getRange("I10"));
// Set range K10:K12 on sheet2
sheet2.getRange("K10:K12").setFormulasLocal([["=sum(i10+j10)"],["=sum(i11+j11)"],["=sum(i12+j12)"]]);
// Set range K15:K16 on sheet2
sheet2.getRange("K15:K16").setFormulasLocal([["=sum(i15+j15)"],["=sum(i16+j16)"]]);
// Set range K18:K19 on sheet2
sheet2.getRange("K18:K19").setFormulasLocal([["=sum(i18+j18)"],["=sum(i19+j19)"]]);
// Set range K21 on sheet2
sheet2.getRange("K21").setFormulaLocal("=sum(i21+j21)");
// Set range K24:K26 on sheet2
sheet2.getRange("K24:K26").setFormulasLocal([["=sum(i24+j24)"],["=sum(i25+j25)"],["=sum(i26+J26)"]]);
// Paste to range C7 on sheet2 from range K7:K30 on sheet2
sheet2.getRange("C7").copyFrom(sheet2.getRange("K7:K30"), ExcelScript.RangeCopyType.values, false, false);
// Clear ExcelScript.ClearApplyTo.contents from range I7:J30 on sheet2
sheet2.getRange("I7:J30").clear(ExcelScript.ClearApplyTo.contents);
// Paste to range I7 on sheet2 from range G7:G34 on sheet2
sheet2.getRange("I7").copyFrom(sheet2.getRange("G7:G34"), ExcelScript.RangeCopyType.values, false, false);
// Paste to range J7 on sheet2 from range AA37 on selectedSheet
sheet2.getRange("J7").copyFrom(selectedSheet.getRange("AA37"), ExcelScript.RangeCopyType.values, false, false);
// Paste to range J9 on sheet2 from range AA38 on selectedSheet
sheet2.getRange("J9").copyFrom(selectedSheet.getRange("AA38"), ExcelScript.RangeCopyType.values, false, false);
// Set range K9 on sheet2
sheet2.getRange("K9").setFormulaLocal("=sum(i9+j9)");
// Paste to range J10 on sheet2 from range AA39:AA40 on selectedSheet
sheet2.getRange("J10").copyFrom(selectedSheet.getRange("AA39:AA40"), ExcelScript.RangeCopyType.values, false, false);
// Set range K12 on sheet2
sheet2.getRange("K12").setValue(" ");
// Paste to range J13 on sheet2 from range AA41 on selectedSheet
sheet2.getRange("J13").copyFrom(selectedSheet.getRange("AA41"), ExcelScript.RangeCopyType.values, false, false);
// Set range K13 on sheet2
sheet2.getRange("K13").setFormulaLocal("=sum(i13+j13)");
// Set range K15 on sheet2
sheet2.getRange("K15").setValue(" ");
// Paste to range J16 on sheet2 from range AA42 on selectedSheet
sheet2.getRange("J16").copyFrom(selectedSheet.getRange("AA42"), ExcelScript.RangeCopyType.values, false, false);
// Paste to range J18 on sheet2 from range AA43:AA44 on selectedSheet
sheet2.getRange("J18").copyFrom(selectedSheet.getRange("AA43:AA44"), ExcelScript.RangeCopyType.values, false, false);
// Set range K21 on sheet2
sheet2.getRange("K21").setValue(" ");
// Paste to range J22 on sheet2 from range AA45:AA46 on selectedSheet
sheet2.getRange("J22").copyFrom(selectedSheet.getRange("AA45:AA46"), ExcelScript.RangeCopyType.all, false, false);
// Clear ExcelScript.ClearApplyTo.contents from range J22:J23 on sheet2
sheet2.getRange("J22:J23").clear(ExcelScript.ClearApplyTo.contents);
// Paste to range J22 on sheet2 from range AA45:AA46 on selectedSheet
sheet2.getRange("J22").copyFrom(selectedSheet.getRange("AA45:AA46"), ExcelScript.RangeCopyType.values, false, false);
// Set range K22:K24 on sheet2
sheet2.getRange("K22:K24").setFormulasLocal([["=sum(i22+j22)"],["=sum(i23+j23)"],[" "]]);
// Clear fill color for range J22:J23 on sheet2
sheet2.getRange("J22:J23").getFormat().getFill().clear();
// Paste to range J25 on sheet2 from range AA47:AA48 on selectedSheet
sheet2.getRange("J25").copyFrom(selectedSheet.getRange("AA47:AA48"), ExcelScript.RangeCopyType.all, false, false);
// Paste to range J25 on sheet2 from range AA47:AA48 on selectedSheet
sheet2.getRange("J25").copyFrom(selectedSheet.getRange("AA47:AA48"), ExcelScript.RangeCopyType.values, false, false);
// Clear fill color for range J25:J26 on sheet2
sheet2.getRange("J25:J26").getFormat().getFill().clear();
// Paste to range J28 on sheet2 from range AA49:AA50 on selectedSheet
sheet2.getRange("J28").copyFrom(selectedSheet.getRange("AA49:AA50"), ExcelScript.RangeCopyType.values, false, false);
// Set range K28:K29 on sheet2
sheet2.getRange("K28:K29").setFormulasLocal([["=sum(i28+j28)"],["=sum(i29+j29)"]]);
// Paste to range J32 on sheet2 from range AA51 on selectedSheet
sheet2.getRange("J32").copyFrom(selectedSheet.getRange("AA51"), ExcelScript.RangeCopyType.values, false, false);
// Clear fill color for range K32 on sheet2
sheet2.getRange("K32").getFormat().getFill().clear();
// Set range K32 on sheet2
sheet2.getRange("K32").setFormulaLocal("=sum(i32+j32)");
// Paste to range G7 on sheet2 from range K7:K32 on sheet2
sheet2.getRange("G7").copyFrom(sheet2.getRange("K7:K32"), ExcelScript.RangeCopyType.values, false, false);
// Clear ExcelScript.ClearApplyTo.contents from range I3:L35 on sheet2
sheet2.getRange("I3:L35").clear(ExcelScript.ClearApplyTo.contents);
let sheet1 = workbook.getWorksheet("Sheet1");
// Clear ExcelScript.ClearApplyTo.contents from range C9:Z11 on sheet1
sheet1.getRange("C9:Z11").clear(ExcelScript.ClearApplyTo.contents);
// Clear ExcelScript.ClearApplyTo.contents from range C14:Z21 on sheet1
sheet1.getRange("C14:Z21").clear(ExcelScript.ClearApplyTo.contents);
// Clear ExcelScript.ClearApplyTo.contents from range C23:Z26 on sheet1
sheet1.getRange("C23:Z26").clear(ExcelScript.ClearApplyTo.contents);
// Clear ExcelScript.ClearApplyTo.contents from range C29:Z32 on sheet1
sheet1.getRange("C29:Z32").clear(ExcelScript.ClearApplyTo.contents);
// Clear ExcelScript.ClearApplyTo.contents from range C34:Z34 on sheet1
sheet1.getRange("C34:Z34").clear(ExcelScript.ClearApplyTo.contents);
// Clear ExcelScript.ClearApplyTo.contents from range C37:Z41 on sheet1
sheet1.getRange("C37:Z41").clear(ExcelScript.ClearApplyTo.contents);
// Clear ExcelScript.ClearApplyTo.contents from range C43:Z46 on sheet1
sheet1.getRange("C43:Z46").clear(ExcelScript.ClearApplyTo.contents);
// Clear ExcelScript.ClearApplyTo.contents from range C48:Z48 on sheet1
sheet1.getRange("C48:Z48").clear(ExcelScript.ClearApplyTo.contents);