Closed Thread
Results 1 to 9 of 9

Dynamic Range in a Formula? Something like End xlDown

  1. #1
    Registered User
    Join Date
    06-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    64

    Dynamic Range in a Formula? Something like End xlDown

    So I have a function in a spreadsheet that needs to target a dynamic range.
    It's a custom function but if you imagine it as the SUM function it will work the same.

    So lets say I have a cell that is "=SUM(CD97:CD288)"
    In the future I'll add another row of data but I want to avoid having to go in manually and changing it to "=SUM(CD97:CD289)"

    What I'm about to propose isn't the correct syntax (I tried it as a shot in the dark) but I think it illustrates what I want well enough:

    "=SUM(CD98:CD97.End(xlDown))" -- I know that's VBA and doesn't belong in a formula (right?) but how can I do this?

    If you have any questions let me know, thanks for the help!

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,876

    Re: Dynamic Range in a Formula? Something like End xlDown

    Select the Table from where the data is derived. Press Ctrl + t.

    This will activate the Tables feature. Re-type the formula again.. And your ranges will be dynamic.

    Else you can also use the offset function.

    Cheers!

    Deep
    Cheers!
    Deep Dave

  3. #3
    Registered User
    Join Date
    06-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    64

    Re: Dynamic Range in a Formula? Something like End xlDown

    Okay, good news bad news.

    Good news: it sort of works. If I go to the end of the range defined as a table and write in a new value the table automatically expands and the value I have set for the formula expands to include the new entry into the table.

    Bad news: when I copy/paste the formula that makes up the cells of the table down another row the table doesn't automatically expand to include it? Any idea why this might be happening? I need it to expand the table automatically when I copy/paste the formula down a row.

  4. #4
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,876

    Re: Dynamic Range in a Formula? Something like End xlDown

    Well the Table feature has a dynamic range which is absolute.. Even if you drag down, it shud call the same range in the formula..

  5. #5
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: Dynamic Range in a Formula? Something like End xlDown

    Why not create a dynamic named range?

    Go to Formulas tab > Name Manager > New... Type the name under Name : - say "RngToSum" and in the Refers To field type the following :
    Please Login or Register  to view this content.
    Replace 10000 with whatever bottom limit you want. OFFSET() function would re-size based on the counts available between the range. Only thing is you'll have to make sure that the rows should be continuously filled for this, otherwise, it might result in some un-expected results.

    And after creating the dynamic named range, you can change your formula to
    Please Login or Register  to view this content.
    cOdEsLiZeR - Back after a long break.. Let's sLiZe some more cOdEs!!

  6. #6
    Registered User
    Join Date
    06-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    64

    Re: Dynamic Range in a Formula? Something like End xlDown

    instead of a having a bottom limit that just extends down as far as I want, could I tell it to only go as far as consecutive non-empty cells go? Similar to the End(xlDown) code works?

  7. #7
    Registered User
    Join Date
    06-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    64

    Re: Dynamic Range in a Formula? Something like End xlDown

    Okay, so I just figured out a solution.
    In case anyone else has a need for this.
    so I need to have this spreadsheet set up so it can be updated in the future, I'm doing that mostly by macro (and now more so).
    To calculate these formulas on a range, I select the range in VBA using .End(xlDown) and then name that range.


    This is what the VBA I just tested looks like

    Please Login or Register  to view this content.
    then I just have the formulas I need, just reference whatever the name is that I give it.

    For instance, I'd have one cell be "=SUM(overall1)"
    and then when I run the macro it will update.

  8. #8
    Registered User
    Join Date
    07-06-2021
    Location
    India
    MS-Off Ver
    office 365
    Posts
    1

    Re: Dynamic Range in a Formula? Something like End xlDown

    Hi,


    How do I make this work for SUMIF's formula where I have it linked to other sheets? I have the same requirement to make the formula dynamic so that when I add more rows at the bottom, the formula updates automatically?

  9. #9
    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. 2407 (Windows 11 23H2 64-bit)
    Posts
    82,886

    Re: Dynamic Range in a Formula? Something like End xlDown

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    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.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. RE-WRITING WITH RANGE.END(xlDown)
    By dalewms2 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-02-2011, 11:09 AM
  2. Xldown formula
    By chedges in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-10-2009, 07:03 AM
  3. Unable to use Range.End(xlDown) method
    By vedpatel in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-01-2006, 12:20 AM
  4. Unable to get last filled cell address from Range.End(xlDown) method
    By vedpatel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2006, 05:15 AM
  5. Replies: 2
    Last Post: 02-02-2006, 04:10 PM

Tags for this Thread

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