+ Reply to Thread
Results 1 to 6 of 6

Dynamic Range Sizes in Formulas

  1. #1
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Dynamic Range Sizes in Formulas

    I had a question on variable length arrays within complicated array formulas, because the data size would change daily, but I couldn't use whole column references because it slowed everything down. While building my sample sheet for upload here, I had an idea and solved my own question. Thought I would share my solution here;

    Scenario: I have values in Column K, starting at K2. I need to SUM them. The number of values is variable.

    Example formula (correct output, slow calculation speed)
    =SUM(K:K)


    Solution:
    =SUM(OFFSET(K2,,,COUNTA(K:K)))



    Note: SUM formula is a placeholder. I know it is not a complicated array function, and I know that this specific example wouldn't be slow enough to need a solution like this. It is just to show how the range is replaced.


    Note 2: This solution assumes no blank rows in Column K.
    Last edited by Speshul; 09-12-2014 at 09:13 AM.
    You should hit F5, because chances are I've edited this post at least 5 times.
    Example of Array Formulas
    Quote Originally Posted by Jacc View Post
    Sorry, your description makes no sense. I just made some formula that looks interesting cause I had nothing else to do.
    Click the * below on any post that helped you.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,443

    Re: Dynamic Range Sizes in Formulas

    There is also a non volatile alternate, if you can reasonably estimate the maximum number of rows likely to be employed:

    =SUM(K2:INDEX(K2:K10000,MATCH(9.99999999999E+307,K2:K10000,1)))

    This will sum all entries between K2 and the last entry in column K (up to K10000), regardless of blanks.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Dynamic Range Sizes in Formulas

    N2=SUM(INDIRECT("K2"&":"&"K"&COUNTA($K$2:$K$50)+1))

    See the attached file.
    Attached Files Attached Files
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Registered User
    Join Date
    08-15-2014
    Location
    St.Petersburg, Russia
    MS-Off Ver
    MSO Excel 2010
    Posts
    20

    Re: Dynamic Range Sizes in Formulas

    Just to note, you also can use dynamic named range (which you can create using OFFSET or INDEX formulas as above) as an argument to SUM

  5. #5
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Dynamic Range Sizes in Formulas

    Quote Originally Posted by sweep View Post
    There is also a non volatile alternate, if you can reasonably estimate the maximum number of rows likely to be employed:

    =SUM(K2:INDEX(K2:K10000,MATCH(9.99999999999E+307,K2:K10000,1)))

    This will sum all entries between K2 and the last entry in column K (up to K10000), regardless of blanks.
    You just answered another thread for me. Thanks!

  6. #6
    Registered User
    Join Date
    09-14-2014
    Location
    The Netherlands
    MS-Off Ver
    2010
    Posts
    5

    Re: Dynamic Range Sizes in Formulas

    damn you guys know alot

+ 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. Insert cells, fill formulas down, set formulas for dynamic range
    By Snickers65 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2013, 01:43 PM
  2. Dynamic table sizes
    By urngoodhands in forum Excel General
    Replies: 2
    Last Post: 11-23-2012, 08:48 PM
  3. [SOLVED] Formulas' on Dynamic Range
    By knocks420 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-09-2012, 02:34 PM
  4. Adding a dynamic range to formulas
    By sans in forum Excel General
    Replies: 20
    Last Post: 12-07-2011, 10:55 AM
  5. dynamic range of formulas
    By dreamz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2006, 03:53 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