+ Reply to Thread
Results 1 to 9 of 9

Best way to name Dynamic ranges

Hybrid View

  1. #1
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Best way to name Dynamic ranges

    Wasn't meant to offend...just commented that the style (i.e.using all those Named Formulas is what I often see Domenic solutions consist of) ... that's all
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Best way to name Dynamic ranges

    OK, here's my tortured approach, similar to DO/Domenic's.

    Suppose we have a table of variable-length data starting with headers starting in D:F with a header in row 6. We want definitions that ensure that adding data to the table (top, bottom, or in between) extends all ranges appropriately to include it, and allows moving the table without hosing the ranges.

    Define:

    ptrTL Refers to: =$D$6
    rgnHdrDown Refers to: =ptrTL:$F$65536
    frmEnd Refers to: (any method appropriate to table contents; sometimes I just use the word End if I really want to have other data below the table)

    This defines everything from the header row downward. The actual data starts one row below that, so we define:

    tbl Refers to: =INDEX(rgnHdrDown, 2, 0):INDEX(rgnHdrDown, frmEnd, 0)

    This makes the table start one row below the header, and extend to the last row.

    Suppose the table contains values for x, y, z in columns D:F respectively. Then define

    ptrX Refers to: =$D$6
    ptrY Refers to: =$E$6
    ptrZ Refers to: =$F$6

    rgnX Refers to: =INDEX(tbl, 0, COLUMNS(ptrTL:ptrX) )
    rgnY Refers to: =INDEX(tbl, 0, COLUMNS(ptrTL:ptrY) )
    rgnX Refers to: =INDEX(tbl, 0, COLUMNS(ptrTL:ptrZ) )

    This seems a little awkward, but it defines the columns in terms of the offsets from the start of the table to their named header cells.
    The approach allows rows to be inserted above, and columns to be inserted to the left or the interior of the table, with ranges adjusting automatically.
    Suppose you want to apply a function (say, SUM) to a particular column. Use this formula in the same column, anywhere above the data:

    =SUM(INDEX(tbl, 0, COLUMNS(ptrTL:Me))
    Last edited by shg; 02-11-2009 at 02:02 PM.
    Entia non sunt multiplicanda sine necessitate

+ 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