+ Reply to Thread
Results 1 to 7 of 7

Thread: Creating Dynamic Named Range in a Row

  1. #1
    Registered User
    Join Date
    08-02-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    7

    Creating Dynamic Named Range in a Row

    Currently, I have range C3:AJ3 named as "MyRange". A3 and B3 are being used as headers.

    I'd like my named range in row 3 to dynamically expand when inserting new columns.

    I've been working on this for a bit and I am stumped on what formula to use.

    Thanks in advance for your help.
    Last edited by Quentyn; 08-21-2011 at 09:51 AM.

  2. #2
    Registered User
    Join Date
    08-10-2011
    Location
    Michigan, USA
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Creating Dynamic Named Range in a Row

    This is what I got:

    =OFFSET(Sheet1!$C$3,0,0,1,COUNTA(Sheet1!$3:$3))
    put that in the Refers to: section of your named range
    When helped,use the icon right of the post #.

  3. #3
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,224

    Re: Creating Dynamic Named Range in a Row

    Close, Zenith, you forgot to remove A:B from the count:

    =OFFSET(Sheet1!$C$3, 0, 0, 1, COUNTA(Sheet1!$3:$3)-2)
    _________________
    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!)

  4. #4
    Valued Forum Contributor MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    5,285

    Re: Creating Dynamic Named Range in a Row

    Hi Quentyn,

    =OFFSET(Sheet1!$C$3,0,0,1,MAX(MATCH(1000,Sheet1!$3:$3,1)))
    did the trick for me.
    See the example sheet with this in it.
    I used 1000 as the Maximum column you would have data in. If it might be larger then increase 1000 to 10000.


    Give all our examples a test. Put numbers and text in row 3 to see if the dynamic range still works correctly.

    Then read http://www.ozgrid.com/Excel/DynamicRanges.htm
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * below to say thanks.

  5. #5
    Registered User
    Join Date
    08-10-2011
    Location
    Michigan, USA
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Creating Dynamic Named Range in a Row

    Yeah I always forget to subtract the extra garbage :P.
    When helped,use the icon right of the post #.

  6. #6
    Registered User
    Join Date
    08-02-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Creating Dynamic Named Range in a Row

    All,

    Thanks so much for your help.

    Quote Originally Posted by MarvinP View Post
    Thanks Marvin. That is actually the site I was working from, and I've learned a lot, both there and here. Where I was stumped was the values to use with the count function. I'm using count as the entries are strictly numeric. I can see the solution was simpler than I was trying to make it.

    Thanks again everyone.

  7. #7
    Valued Forum Contributor MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    5,285

    Re: Creating Dynamic Named Range in a Row

    Hi Quentyn,

    The problem got harder if you insered a blank column or two. If the DNR only counted numbers then it would be blank cells short from the last column to sum. The CountA function counts the number of cells that aren't empty. You could also use Count() which only count numbers in the range. Both give you problems when trying to use them in a DNR. You really wanted the last column number that had anything in it. That is where the Max(Match()) part of my formula came from.

    Then to be better at defining the DNR, because you started in Column 3 instead of 1, I should have subtracted a few like Jerry did.

    I'm glad you found an answer.
    One test is worth a thousand opinions.
    Click the * below to say thanks.

+ 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.2.0