简体   繁体   中英

replace volatile OFFSET in an excel SUMPRODUCT

I'm using Frontline's solver in excel and in some models the whole process is slowed down probably due to the heavy use of the excel function OFFSET . According to my research this function is considered volatile and should be avoided. Apparently one can replace the use of offset by INDEX . What I need to offset is a vector rather than just a value, to be used in a SUMPRODUCT . Something like SUMPRODUCT(array,OFFSET(vector)) . INDEX seems to only be able to output a value rather than a vector.

Attached is a screenshot of a minimal example showing what I have as a formula. The yellow and blue cells are all fixed whereas the formula is in the green cells. The value in cell B11 is 16.

在此处输入图片说明

So my question: How can one replace the volatile OFFSET by something that's not volatile?

You can use INDEX. Replace your function with the following

=SUMPRODUCT(B$6:B$8,INDEX($F$6:$I$8,0,1))

The INDEX function in this case returns the first column values of the area F6:I8. The 0 returns the all rows, and the 1 returns the 1st column. You probably want to replace the 1 with COLUMN()-1 so you can copy the formula across but ideally you would do this with an array formula, but that's another question.

One tip I find really useful when working with functions is the ability to highlight part of the function in the function bar and calculate just that part by pressing F9. So if you highlight "INDEX($F$6:$I$8,0,1)" and press F9 it will show you which value(s) it is using.

From https://support.office.com/en-gb/article/INDEX-function-a5dcf0dd-996d-40a4-a822-b56b061328bd

"If you set Row_num or Column_num to 0 (zero), INDEX returns the array of values for the entire column or row, respectively. To use values returned as an array, enter the INDEX function as an array formula in a horizontal range of cells for a row, and in a vertical range of cells for a column.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM