+ Reply to Thread
Results 1 to 5 of 5

Better way to index

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-15-2010
    Location
    Oklahoma
    MS-Off Ver
    Excel 2019
    Posts
    168

    Question Better way to index

    I record expense reports monthly by totaling the sum for each employee. An indexing formula worked fine until we began to grow, and now the same formula takes a long time and locks up Excel for a period while returning results. Can you provide a better formula or method to obtain the same result? I uploaded a sample of what we're using now.

    Regards,
    Gary
    Attached Files Attached Files
    Last edited by allgeef; 03-17-2011 at 11:15 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Better way to index

    In G2 entered as an array:

    =INDEX(E$2:E$1000,MATCH(0,COUNTIF(E$2:E$1000,"<"&E$2:E$1000),0))


    In G3 entered as an array, then copied down about 40-50 rows:

    =IF(COUNTIF(E$2:E$1000,">"&G2), INDEX(E$2:E$1000, MATCH(COUNTIF(E$2:E$1000,"<="&G2), COUNTIF(E$2:E$1000,"<"&E$2:E$1000),0)),"")


    I also fixed the other formulas...in H2 entered as a normal formula and copied down:

    =IF(G2="","",SUMIF(E:E,G2,C:C))

    In I2 and copied down:

    =IF(G2="","",COUNTIF(E:E,G2))
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Better way to index

    Given the nature of your data and the fact you want to do this as efficiently as possible with formulae (rather than using a Pivot) I'd suggest:

    G1: 
    Account Name
    [rather than name]
    
    G2:
    =IFERROR(IF(LOOKUP(REPT("Z",255),$E$1:$E$1000)=$G1,"",LOOKUP($G1,$E$1:$E$10000,$E$2:$E$10001)),"")
    copied down as nec.
    
    H2:
    =IF($G2="","",SUMIF($E:$E,$G2,$C:$C))
    copied down as nec.
    
    I2:
    =IF($G2="","",COUNTIF($E:$E,$G2))
    copied down as nec.
    The LOOKUP above assumes that your data is sorted by Account Name which would seem to be the case given sample - used in this form it is an extremely efficient formula (binary search)

    Calculation time for your matrix using the above would be around 0.002 seconds.

  4. #4
    Forum Contributor
    Join Date
    06-15-2010
    Location
    Oklahoma
    MS-Off Ver
    Excel 2019
    Posts
    168

    Re: Better way to index

    Jerry, this is precisely the answer to our problem. Thanks much for the quick response and taking time to make our spreadsheet functional. Regards, Gary

    PS: your web page of Files & Macros looks like it could be a great aid for us.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Better way to index

    Glad to help.

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ 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