Search code examples
arraysexceloffset

Use array to vary the row/column in an offset in Excel formula


Looking for a way to use an array of numbers as the offset entry in an OFFSET formula.

Data setup: - I have a table with three columns that represent low/medium/high options - I want to add a fourth column where the user enters 1/2/3 as their low/medium/high selection - I want to then have a cell at the bottom that sums up the selection options

Example

enter image description here

  • User inputs in yellow cells
  • Formula goes in orange cell
  • Formula should output the sum of the green cells which are the choices in each row per the yellow cell

I have tried array formula variations of {=SUM(OFFSET([column 0],0,[column 4]))} i.e. set the anchor for the offset as one column left of the "low" options column and then the numbers 1/2/3 in column 4 to feed in as the column offset

Any ideas?


Solution

  • You need to force INDEX to use an array as input:

    =SUM(INDEX(B:D,N(IF({1},ROW(B3:D5))),N(IF({1},(F3:F5)))))
    

    Depending on ones's version of Excel this will need to confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.

    enter image description here


    If one has a subscription to Office 365 that has the dynamic array formula, Microsoft fixed the need for the forcing the array:

    =SUM(INDEX(B:D,ROW(B3:D5),F3:F5))