+ Reply to Thread
Results 1 to 7 of 7

Dynamic Named Range

  1. #1
    Registered User
    Join Date
    09-07-2008
    Location
    Middletown
    Posts
    33

    Dynamic Named Range

    Hello all,

    I'm trying to create a dynamic named range to use as a source for my pivot table data. I've attached my xlsm doc to make it easier to follow.

    Essentially, I have a sheet titled, 'Long'. Towards the bottom under week ending 7/22 from cells B128:T129 I need to make it a named range to act as a source for my pivot table. Each week I post a new data set so for example next week ending, 7/29 the named range would be from cells B161:T162.

    So my question is, in the Refers to box of a named range, what code do I write so it keeps changing?

    Thanks,

    Mark
    Attached Files Attached Files
    Last edited by nirvehex; 07-27-2011 at 11:18 PM.

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Dynamic Named Range

    =INDIRECT("Long!$B$"&(COUNTA(Long!$B:$B)-1)&":$B$"&COUNTA(Long!$B:$B))

  3. #3
    Registered User
    Join Date
    09-07-2008
    Location
    Middletown
    Posts
    33

    Cool Re: Dynamic Named Range

    Kenneth,

    This sort of worked. Only this range started at Week Ending 7/29 and only highlighted B161:B162. I need it to start at B128:T129, and do B161:T162, and so forth as I add more rows. Is this possible?

    Here's what I used for selecting a previous range: =Long!$A$1:INDEX(Long!$A:$IV,MATCH(9.99E+307,Long!$A:$A),MATCH(REPT("Z",255),Long!$1:$1)). This goes through my entire worksheet and is used a source for my pivot table to return only a certain range of cells which is modified each week. I just need to select part of my table now so I need to modify this to select just the ranges I mentioned above.

    Thanks,

    Mark
    Last edited by nirvehex; 07-25-2011 at 06:24 PM.

  4. #4
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Dynamic Named Range

    If you want the B and T then:
    =INDIRECT("Long!$B$"&(COUNTA(Long!$B:$B)-1)&":$T$"&COUNTA(Long!$B:$B))

    I don't know what the rules are for selecting previous range.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Dynamic Named Range

    You are using a Table in the sheet. The Table name can be used as the source for the PivotTable, the table will expand as Rows are added
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    09-07-2008
    Location
    Middletown
    Posts
    33

    Cool Re: Dynamic Named Range

    Quote Originally Posted by royUK View Post
    You are using a Table in the sheet. The Table name can be used as the source for the PivotTable, the table will expand as Rows are added
    Roy,

    The table does not encompass those cells. I also need to make the dynamic range include previous cells. Essentially, I have a sheet titled, 'Long'. Towards the bottom under week ending 7/22 from cells B128:T129 I need to make it a named range to act as a source for my pivot table. Each week I post a new data set so for example next week ending, 7/29 the named range would be from cells B161:T162.

    So my question is, in the Refers to box of a named range, what code do I write so it keeps changing? As of now the code that Kenneth gave me, =INDIRECT("Long!$B$"&(COUNTA(Long!$B:$B)-1)&":$T$"&COUNTA(Long!$B:$B)) works for one of the data sets, B161:T162, but does not include B128:T129 and will not include more as I add more.

    I also combined some earlier code that I had with Kenneth's code to come up with, =Long!$B$1:INDIRECT("Long!$B$"&(COUNTA(Long!$B:$B)-1)&":$T$"&COUNTA(Long!$B:$B)). This selects my worksheet instead of the two summary rows that I need to select. So each week I will have summary rows that take up the last two rows of my data set. I need to source just these two rows each week for a pivot table. I'm hoping to create a dynamic range that just selects those two rows from each week. Then I will filter my pivot table by week ending to see these results.

    Thanks for your help!

    -Mark


    Thanks,

    Mark
    Last edited by nirvehex; 07-26-2011 at 04:55 PM. Reason: More info

  7. #7
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Dynamic Named Range

    To get the previous:
    =INDIRECT("Long!$B$"&(COUNTA(Long!$B:$B)-35)&":$T$"&COUNTA(Long!$B:$B)-34)

+ 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