+ Reply to Thread
Results 1 to 11 of 11

Replacement of Indirect Function for Variable Size Range

  1. #1
    Registered User
    Join Date
    04-30-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    3

    Replacement of Indirect Function for Variable Size Range

    Hi,

    I'm currently using the INDIRECT function to vary the size of a range specified within an OFFSET function.

    See attached example.

    In this example, I use the following formula to break up the list of data into discrete groups and then find the maximum value with that group. The reason for using the indirect function is that the size of the groups vary depending upon the case I'm looking at. So I may want 3 items in the group, or 4 or 5. If you vary the Yellow cell you'll see how the data changes. (For the purpose of this file I simply use a RAND() generator to generate a random set of data.).

    =MAX(OFFSET(INDIRECT("b1:b"&E$2),E$2*(D7-1),0))

    I'd like to replace this formula with one that doesn't use the INDIRECT function as it is impacting the performance of the spreadsheet and I'm getting error messages due to volatility.

    Any help is appreciated! Thanks,
    AB

    Indirect and Offset.xlsx

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Replacement of Indirect Function for Variable Size Range

    Try this in E6 and filled down

    =MAX(OFFSET($B$1,(D6-1)*$E$2,0,$E$2,1))

  3. #3
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: Replacement of Indirect Function for Variable Size Range

    To also eliminate all volatile functions OFFSET is also volatile), try
    Please Login or Register  to view this content.

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Replacement of Indirect Function for Variable Size Range

    I think I read somewhere that INDEX:INDEX is also volatile.
    Not index by itself, but the syntax of Index:Index
    Or even just A1:INDEX(...) or INDEX(..):A100

    To avoid volitile functions alltogether, try this array formula entered with CTRL + SHIFT + ENTER
    =MAX(IF($A$1:$A$27>=((D6-1)*$E$2)+1,IF($A$1:$A$27<=D6*$E$2,$B$1:$B$27)))

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Replacement of Indirect Function for Variable Size Range

    it's semi-volatile so it only recalculates on workbook open not on every calculation
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  6. #6
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: Replacement of Indirect Function for Variable Size Range

    Quote Originally Posted by Jonmo1 View Post
    I think I read somewhere that INDEX:INDEX is also volatile.
    Not index by itself, but the syntax of Index:Index
    Or even just A1:INDEX(...) or INDEX(..):A100

    To avoid volitile functions alltogether, try this array formula entered with CTRL + SHIFT + ENTER
    =MAX(IF($A$1:$A$27>=((D6-1)*$E$2)+1,IF($A$1:$A$27<=D6*$E$2,$B$1:$B$27)))
    Will an array formula improve performance? I have my doubts
    INDEX is documented as volatile by MS, but in fact is not when tested

  7. #7
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Replacement of Indirect Function for Variable Size Range

    Well the OP's goal according to the title was just to eliminate Indirect.
    Which was acccomplished.

    Then somehow it got switched to eliminating all volatile functions...though not by the OP.

  8. #8
    Registered User
    Join Date
    04-30-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Replacement of Indirect Function for Variable Size Range

    While my original question did ask for a replacement for the INDIRECT function I was really looking for a way to make the formula not volatile. I'm dealing with a significant amount of data to post process.

    I'll try some of the suggestions and compare how each work.

    Thanks!
    AB

  9. #9
    Registered User
    Join Date
    04-30-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Replacement of Indirect Function for Variable Size Range

    So I tried replacing with ARRAYS and now my sheet has slowed to a crawl. I have to stop the recalculation process as it is taking way too long (8 Core Intel i7 2.8 GHz with 16 GB RAM). It is currently at 3% after about 5 minutes.

    I may have no choice but to start looking into VBA if the INDIRECT and OFFSET functions are volatile and if arrays are too slow.

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Replacement of Indirect Function for Variable Size Range

    variation of Pepe's
    =MAX(INDEX($B:$B,(D6-1)*$E$2+1):INDEX($B:$B,(D6*$E$2)))

  11. #11
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Replacement of Indirect Function for Variable Size Range

    Try any of this in E6 (See attached file).

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 05-01-2013 at 09:01 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1