Skip to content

Commit

Permalink
Merge pull request #20 from ORNL-AMO/fix-chaining
Browse files Browse the repository at this point in the history
Added '@' syntax for dynamic array formula
  • Loading branch information
gaccawi authored Jun 11, 2020
2 parents 74ba6c2 + 1515c4c commit 279e1bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions AMO.EnPI-5.0/AMO.EnPI.AddIn/EnPISheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ internal void AddSubtotalColumns()

//Caclulate Annual Savings
string unadjustedTotalColName = ((isSEnPI == false) ? Globals.ThisAddIn.rsc.GetString("unadjustedTotalColName") : Globals.ThisAddIn.rsc.GetString("unadjustedSEPTotalColName"));
string before = "OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),0,-1,1,1) + ((INDEX(" + SummaryData.Name + ",MATCH(\"" + unadjustedTotalColName + "\"," + SummaryData.Name + "[[ ]],0),COLUMN()-1)-INDEX(" + SummaryData.Name + ",MATCH(\"" + Globals.ThisAddIn.rsc.GetString("totalAdjValuesColName") + "\"," + SummaryData.Name + "[[ ]],0),COLUMN()-1))-(INDEX(" + SummaryData.Name + ",MATCH(\"" + unadjustedTotalColName + "\"," + SummaryData.Name + "[[ ]],0),)-INDEX(" + SummaryData.Name + ",MATCH(\"" + Globals.ThisAddIn.rsc.GetString("totalAdjValuesColName") + "\"," + SummaryData.Name + "[[ ]],0),)))";
string after = "INDEX(" + SummaryData.Name + ",MATCH(\"" + Globals.ThisAddIn.rsc.GetString("totalAdjValuesColName") + "\"," + SummaryData.Name + "[[ ]],0),)-INDEX(" + SummaryData.Name + ",MATCH(\"" + unadjustedTotalColName + "\"," + SummaryData.Name + "[[ ]],0),)";
string before = "OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),0,-1,1,1) + ((@INDEX(" + SummaryData.Name + ",MATCH(\"" + unadjustedTotalColName + "\"," + SummaryData.Name + "[[ ]],0),COLUMN()-1)-@INDEX(" + SummaryData.Name + ",MATCH(\"" + Globals.ThisAddIn.rsc.GetString("totalAdjValuesColName") + "\"," + SummaryData.Name + "[[ ]],0),COLUMN()-1))-(@INDEX(" + SummaryData.Name + ",MATCH(\"" + unadjustedTotalColName + "\"," + SummaryData.Name + "[[ ]],0),)-@INDEX(" + SummaryData.Name + ",MATCH(\"" + Globals.ThisAddIn.rsc.GetString("totalAdjValuesColName") + "\"," + SummaryData.Name + "[[ ]],0),)))";
string after = "@INDEX(" + SummaryData.Name + ",MATCH(\"" + Globals.ThisAddIn.rsc.GetString("totalAdjValuesColName") + "\"," + SummaryData.Name + "[[ ]],0),)-@INDEX(" + SummaryData.Name + ",MATCH(\"" + unadjustedTotalColName + "\"," + SummaryData.Name + "[[ ]],0),)";
Excel.ListRow annualSavingsRow = SummaryData.ListRows.Add(System.Type.Missing);
if (modelIndex.Equals(2) || modelIndex.Equals(SummaryData.ListColumns.Count))
annualSavingsRow.Range.Formula = VaryingRowFormula(modelIndex, annualSavingsRow, before, after);
Expand Down

0 comments on commit 279e1bb

Please sign in to comment.