+ Reply to Thread
Results 1 to 4 of 4

Slow Array Formula

  1. #1
    Forum Contributor
    Join Date
    11-14-2004
    Location
    Watford, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    131

    Slow Array Formula

    Hi All,

    I have an array formula that does do what I want but is very slow to run and I was wondering if there is anything I can do to speed it up.

    The formula is located on the "RUN SHEET" in the green cells.

    What it does is look for "RUN SHEET" K1 on the data tab and then return data to the green cells, so if I change the data in K1 the data in the green cells will change.

    The "DATA SHEET" will be quite long maybe up to 1000 rows

    Is there anything I can do to speed this up?

    Sample File Attached

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Slow Array Formula

    In similar case, I always create helper array column to find out interesting rows.
    Then based on that values by INDEX displaying values from other columns.

    M
    N
    O
    P
    Q
    R
    10
    helper
    depart site
    depart time
    Arr Time
    To Site
    PLANZ Code
    11
    2
    STARTING OFFICE
    05:40
    06:16
    DESTINATION 1
    .HWDC.5
    12
    3
    DESTINATION 1
    06:31
    07:07
    STARTING OFFICE
    EMPTY
    13
    4
    STARTING OFFICE
    07:22
    08:02
    DESTINATION 2
    RY..PRDC.
    14
    5
    DESTINATION 2
    08:17
    09:07
    DESTINATION 1
    EMPTY
    15
    6
    DESTINATION 1
    10:37
    11:27
    DESTINATION 2
    HWILC.PRDC.
    16
    7
    DESTINATION 2
    15:07
    15:26
    STARTING OFFICE
    PRDC..


    M
    N
    O
    P
    Q
    R
    10
    helper
    depart site
    depart time
    Arr Time
    To Site
    PLANZ Code
    11
    =IFERROR(SMALL(IF('RUN SHEET'!$K$1=DATA!$A:$A,MATCH(ROW(DATA!$A:$A),ROW(DATA!$A:$A)),""),ROWS($A$1:E1)),"")
    =IF($M11<>"",INDEX(DATA!$G:$G,'RUN SHEET'!$M11),"")
    =IF($M11<>"",INDEX(DATA!$B:$B,'RUN SHEET'!$M11),"")
    =IF($M11<>"",INDEX(DATA!$C:$C,'RUN SHEET'!$M11),"")
    =IF($M11<>"",INDEX(DATA!$H:$H,'RUN SHEET'!$M11),"")
    =IF($M11<>"",INDEX(DATA!$E:$E,'RUN SHEET'!$M11),"")
    12
    =IFERROR(SMALL(IF('RUN SHEET'!$K$1=DATA!$A:$A,MATCH(ROW(DATA!$A:$A),ROW(DATA!$A:$A)),""),ROWS($A$1:E2)),"")
    =IF($M12<>"",INDEX(DATA!$G:$G,'RUN SHEET'!$M12),"")
    =IF($M12<>"",INDEX(DATA!$B:$B,'RUN SHEET'!$M12),"")
    =IF($M12<>"",INDEX(DATA!$C:$C,'RUN SHEET'!$M12),"")
    =IF($M12<>"",INDEX(DATA!$H:$H,'RUN SHEET'!$M12),"")
    =IF($M12<>"",INDEX(DATA!$E:$E,'RUN SHEET'!$M12),"")


    As you can see there is only array formula in helper column, the rest of columns are displayed based on INDEX.

    Your sample file opens (on my pc) around 18 seconds, attached file around 1 seconds.
    Attached Files Attached Files
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Slow Array Formula

    The reason it's slow, is you are looking at entire columns (over 1 million cells).
    If you limit it to a reasonable range it will improve performance.
    Alternatively you could use use one of the newer functions
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This would go in A11, but clear the other formulas first.

  4. #4
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,830

    Re: Slow Array Formula

    And adding on to what Fluff13 has said, I'd recommend (if it's possible of course), to put your data into an Excel Table. Therefore your formulas expand as your data expands and you're not referencing the whole column, and you'll be referencing exactly the size you need. If you put it in a table and call it "Table1", using Fluff13's formula, it would be:

    =LET(f,FILTER(Table1,Table1[Duty ID]=K1),INDEX(f,SEQUENCE(ROWS(f)),{7,2,3,8,5,6}))

    Another option is this:
    =FILTER(INDEX(Table1,SEQUENCE(ROWS(Table1)),XMATCH({"From Site","Dep Time","Arr Time","To Site","PLANZ Code","Due to Convey"},Table1[#Headers])),Table1[Duty ID]=K1,"No Data")

    (I removed your line feed for Dep Time and Arr time headers to make the above work)

    Pros/cons of the first formula - you can change the column header names and the formula will still work. However, at some point if you insert, delete or move a column, you'll need to change the formula appropriately.
    Pros/cons of the second formula - you can move/delete/insert columns anywhere you want and it will still work (of course as long as you don't delete a column that's being displayed). However, if you change a column header, you'll need to change the formula appropriately.

    Attached is a file that shows the results of this (first formula is in A11, the second formula is put in A18 of the attached).
    Attached Files Attached Files

+ 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] Array Formula too slow in calculation
    By Barieq in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-23-2020, 03:01 AM
  2. [SOLVED] Array formula working too slow
    By pezalmendra in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-19-2019, 10:06 AM
  3. [SOLVED] Excel getting slow with INDEX array formula
    By Lovemyexcel in forum Excel Formulas & Functions
    Replies: 25
    Last Post: 02-19-2017, 11:11 AM
  4. [SOLVED] VBA Code Slow - Use an array instead?
    By CC268 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2017, 11:10 AM
  5. [SOLVED] Slow Array formula
    By gassiusmax in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-09-2015, 12:41 PM
  6. [SOLVED] Array formula too slow. Need an alternative..
    By cool_anu4u in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-28-2013, 04:56 AM
  7. MY ARRAY FORMULA IS SLOW IF DATA LIST IS MORE THAN 10000R0WS
    By S.DURAIVEL - ABU DHABI in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2005, 05:10 AM

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