+ Reply to Thread
Results 1 to 16 of 16

Replace INDIRECT in formula

  1. #1
    Registered User
    Join Date
    01-13-2021
    Location
    US
    MS-Off Ver
    Microsoft 365
    Posts
    7

    Replace INDIRECT in formula

    The formula below works as intended, but I would like to replace the INDIRECT piece of this formula with a less volatile option. Any suggestions? I've attached a small sample file.

    =SUM(B5:INDIRECT("B"&LOOKUP(2,1/(NOT(ISBLANK(B5:B20))),ROW(B5:B20))))
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Replace INDIRECT in formula

    So... what is wrong with:

    =SUM(B:B)

    or

    =SUM($B$5:$B$10000)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    01-13-2021
    Location
    US
    MS-Off Ver
    Microsoft 365
    Posts
    7

    Re: Replace INDIRECT in formula

    Thanks for the reply Glenn. The spreadsheet I'm working with is massive (30-35GB), so I prefer to not reference entire columns and I want to use the last row in the range (which varies over time) to keep the formula recalculation time as efficient as possible.

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

    Re: Replace INDIRECT in formula

    ARRAY formula

    =SUM($B$5:INDEX($B$5:$B$500000,MATCH(2,1/($B$5:$B$500000>0),1)))

    To enter ARRAY formula
    Copy and paste the formula in cell
    Press F2
    Press Ctrl+Shift+Enter together
    Excel covers the formula with {}.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,416

    Re: Replace INDIRECT in formula

    If it's to do with efficiency, have you tried SUMIF?

    =SUMIF(J:J,"<>")

    https://exceloffthegrid.com/optimize...iple-criteria/
    Last edited by AliGW; 02-06-2021 at 11:53 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Replace INDIRECT in formula

    I hate to have to contradict you, but... you're wrong.

    Here are the formulae, in order of speed:

    1 SUM from 5-end. Time per calculation: 0.000101447
    2. Whole column SUM. Time per calculation: 0.000103474
    3. SUMIF Time per calculation: 0.000117064
    4. Array formula. Time per calculation: 0.064025875 (hugely slow by comparison)


    I suggest you read this article.

    https://fastexcel.wordpress.com/2015...a-or-bad-idea/


    However, you are ABSOLUTELY correct to want to move away from INDIRECT. On a sheet that size, it will be a disaster.

  7. #7
    Registered User
    Join Date
    01-13-2021
    Location
    US
    MS-Off Ver
    Microsoft 365
    Posts
    7

    Re: Replace INDIRECT in formula

    Thanks to all for your help! kvsrinivasamurthy I believe your suggestion meets my need at the moment. I just used your formula without entering it as an array, just as a normal formula without the {} and that seems to work for me. Glenn and AliGW, in the file I'm working with I had been using a number of SUMIF and SUMIFS with large ranges (e.g. an entire column) and it seemed to be dragging down my recalc time. If I narrowed the applicable range, I noticed an improvement in the processing time. Not an issue for me in smaller files. Appreciate your time! I'll circle back if my current path breaks down.
    Last edited by tjebme; 02-06-2021 at 01:04 PM.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,416

    Re: Replace INDIRECT in formula

    Were you addressing the OP or me, Glenn?

    Certainly seems that my hunch about SUMIF will be of no benefit.

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Replace INDIRECT in formula

    The OP... who seems to be going off in ENTIRELY the wrong direction here. The array formula will be hopeless.

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,416

    Re: Replace INDIRECT in formula

    I certainly agree with you on that!

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Replace INDIRECT in formula

    I added in a few other options. IYou'll see that the results differ, this is because I added a value in way down near the end of each formula's range.

    It is no surprise thta the array formula is hopeless.

    I was surprised that SUMIF was also very slow, when it had to calculate to the end of the column. I was also a little surprised that the whole column SUM was slower by a factor of 2 than any of the other fixed-range SUMS.

    Bottom line, anything up to 100K rows is zippy fast with SUM. SUMIF is about 10x slower and the array.... about 700 times slower.
    Attached Files Attached Files
    Last edited by Glenn Kennedy; 02-06-2021 at 01:28 PM.

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Replace INDIRECT in formula

    Any improvement in processing time will be due to the removal of the INDIRECTs.

  13. #13
    Registered User
    Join Date
    01-13-2021
    Location
    US
    MS-Off Ver
    Microsoft 365
    Posts
    7

    Re: Replace INDIRECT in formula

    Thanks Glenn! When I get a chance I'll experiment more based on your feedback.

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Replace INDIRECT in formula

    Have you heard of Dynamic Named Ranges? These are a smart alternative to fixed ranges. They auto-adjust to the length of your dataset, without you having to keep fiddling with them. I haven't done any systematic evaluation of their speed... but I think I'll spend the last 20 minutes of my session here, today, doing just that.

    Do the majority of your formulae refer to columns that are blank, but which also have formulae in them (ie the blanks are formula blanks - null strings) or are they just blanks in the data ... ie the cells are EMPTY.

    There is a big difference between an empty cell and a blank cell. More reading for you...

    https://colinlegg.wordpress.com/2014...lank-or-empty/

    So... in general, are the target cells for your formulae blank... or empty?

  15. #15
    Registered User
    Join Date
    01-13-2021
    Location
    US
    MS-Off Ver
    Microsoft 365
    Posts
    7

    Re: Replace INDIRECT in formula

    A mix on the target cells, but the majority would likely be formula blanks. I don't have much experience with the dynamic named ranges. Thank you!

  16. #16
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Replace INDIRECT in formula

    OK. I'm off in a few moments for the night. I'll write a note to myself to come back to you in the am wrt DNRs.

    If, by the time you surface tomorrow, I have not replied (I've a mind like a sieve...) send me a PM to remind me.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Is it possible to replace a sheet row reference with indirect formula?
    By ExcellingOcfUpsides in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-31-2019, 08:03 AM
  2. Replace indirect formula
    By helpmeplz_ in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-10-2018, 06:13 PM
  3. Replace Indirect() in formula
    By CRIMEDOG in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-30-2018, 04:52 PM
  4. [SOLVED] Replace the INDIRECT() part in a formula
    By billj in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-08-2017, 04:44 AM
  5. Macro for division with absolute cell references to replace Indirect formula?
    By naira in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-14-2013, 01:37 AM
  6. [SOLVED] Use indirect to replace tab name.
    By narrowgate88 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-02-2013, 04:17 PM
  7. [SOLVED] How can I replace the range with a Name in a INDIRECT Formula?
    By trizzo in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-02-2013, 04:31 PM

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