+ Reply to Thread
Results 1 to 13 of 13

Dynamic Named Range not working as expected

  1. #1
    Registered User
    Join Date
    09-07-2010
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2007
    Posts
    41

    Dynamic Named Range not working as expected

    Hi,

    I have a dynamic named range that works as expected in all but one situation. That situation is when data is not entered in the first row cell but is in the rest of the row cells.

    When this happens the Dynamic Named range is not picking up the row of data.

    For example: In a table of Columns A, B, C and Rows 1, 2, 3.

    The data in the table is:
    A B C
    1 1 2 3
    2 4 5 6
    3 8 9

    In this case it would not be picking up row 3 as nothing is entered in cell A3.

    The formula I am using for my data is:

    =OFFSET(Incidence!$F$2,1,0,COUNTA(Incidence!$F:$F)-1,3)

    Could anyone offer some help please.

    Thank you.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Dynamic Named Range not working as expected

    Hi Leon,

    The CountA function counts how many cells are not blank in column F in your formula above. If you have a blank cell in Column F the last row would not be included in the DNR. To better see what you mean we need a sample workbook.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    09-07-2010
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Dynamic Named Range not working as expected

    Many thanks for taking the time to reply.

    I have attached a sample workbook as requested.

    Hopefully that should explain things easier.
    Attached Files Attached Files

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Dynamic Named Range not working as expected

    Hi Leon,

    Try this insteat:

    =OFFSET(Incidence!$F$2,1,0,COUNTA(Incidence!$F:$F),3) or even
    =OFFSET(Incidence!$F$2,1,0,COUNTA(Incidence!$B:$B),3)

  5. #5
    Registered User
    Join Date
    09-07-2010
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Dynamic Named Range not working as expected

    Thank you for taking the time to download and look at my problem. I thought you had cracked it with a simple solution (another of those, fresh eyes seeing the obvious answer) but unfortunately that formula doesn't work if further rows of data are added say with nothing in F again but data in G & H.

    It doesn't expand the named range down to include the additional row of data.

    I have attached a new example with your two suggestions included in the named rages.

    Any further suggestions welcome!

    v2_Sample_Workbook_13_04_2015.xlsx

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Dynamic Named Range not working as expected

    Given that example..
    What range do you actually WANT the dynamic named range to refer to? And Why?

  7. #7
    Registered User
    Join Date
    09-07-2010
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Dynamic Named Range not working as expected

    Thank you for your reply.

    I want the Dynamic Named Range to refer to F3:H11 in the v2_Sample_Workbook I attached previously. Though I want this to expand as more rows of data are added.

    The reason for this is that the table forms part of a much larger Spreadsheet. On another tab I have cells that will look back to this table and enter what ever value is in the row.

    This works as expected apart from when there is no data in the first cell of the data named range, i.e. Column F is blank. If that cell is blank I just get #REF! returned in my other tab and none of the data is populated as it is trying to look up a named range that doesn't extend down to that row due to the named range being based on the F column.

    Hopefully that makes sense?

    I can make up another sample spreadsheet which shows this better but the reason I have not so far is that it will take some time to strip out the private data. But if needs be I can do this.

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Dynamic Named Range not working as expected

    The COUNTA part of the formula should look at a column that ALWAYS contains data in every row.
    In your given example, that's either C D or E.
    Personally, I'd go With D

    =OFFSET(Incidence!$F$2,1,0,COUNTA(Incidence!$D:$D)-1,3)

  9. #9
    Registered User
    Join Date
    09-07-2010
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Dynamic Named Range not working as expected

    Thank you for the reply - I take it then that the COUNTA only works when as you say there is data in every row of a particular column.

    I will have to have a think about how I go about implementing this, making it a requirement that at least one column has to have data. I'll also think about if I can do some sort or workaround with hidden columns for example that count the number of blank cells or something as this will always return a result even if the user were to forget to enter data in at least one of the cells and then this count of blank cells could be used for the COUNTA part of the function.

    Time to get my thinking cap on, suggestions welcome!

  10. #10
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Dynamic Named Range not working as expected

    Quote Originally Posted by Leonthefixer View Post
    I take it then that the COUNTA only works when as you say there is data in every row of a particular column.
    No I wouldn't say that..

    COUNTA always works.
    Perhaps it just doesn't do what you thought it does.
    The only thing counta does is count how many Non-Blank Cells exist in the referenced range.

    The root if your issue may simply be not fully understanding exactly how your dynamic named range formula works.
    I hope that doesn't sound mean, I didn't intend it that way.

    The syntax of OFFSET is
    =OFFSET(Range, #ofRows, #ofColumns, Height, Width)

    Range = Starting range reference.
    #ofRows = how many rows away from Range do you want to offset?
    #ofColumns = how many columns away from Range do you want to offset?
    Height = How many rows should the resulting range contain?
    Width = How many columns should the resulting range contain?

    So breaking down your original formula, using the book you attached.
    =OFFSET(Incidence!$F$2,1,0,COUNTA(Incidence!$F:$F)-1,3)

    COUNTA(Incidence!$F:$F) = 5 (there are 5 non blank cells in column F)

    =OFFSET(Incidence!$F$2,1,0,5-1,3)

    5-1=4

    =OFFSET(Incidence!$F$2,1,0,4,3)

    1 Row and 0 columns Away from F2 is F3
    So a range beginning in F3 that is 4 rows high and 3 columns wide is F3:H6


    If using Counta to determine the height of your named range, then yes the counta part must refer to a range that contains no blanks.

    Other methods can be used to determine the ending cell of a named range.
    And some can deal with blanks in the range.
    However, whatever method is used, at some point you must refer to a column that it will be known to have data in the last cell.
    Last edited by Jonmo1; 04-13-2015 at 01:58 PM.

  11. #11
    Registered User
    Join Date
    09-07-2010
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Dynamic Named Range not working as expected

    Thank you for taking the time to provide such a detailed reply. I shall look into it further later today. Many thanks!

  12. #12
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Dynamic Named Range not working as expected

    You're welcome.

  13. #13
    Registered User
    Join Date
    09-07-2010
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Dynamic Named Range not working as expected

    As by way of an update - I used the information you provided and solved the problem by referring to a column that will always have data in the last cell. Many thanks for the solution and your time.

+ 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. [SOLVED] dynamic named range not populating combo box list if range = single cell
    By HeyInKy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-24-2014, 05:27 PM
  2. [SOLVED] Dynamic Named Range to Auto-Populate another range based on criteria
    By BeachRock in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-24-2014, 06:46 PM
  3. [SOLVED] VBA Dynamic Validation List Entry Not Working As Expected
    By acerzw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-27-2013, 04:52 PM
  4. [SOLVED] combobox dynamic range doesn't work as expected
    By florin_excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-21-2012, 09:28 AM
  5. Named ranges-Should I use a dynamic named range
    By foseco in forum Excel General
    Replies: 4
    Last Post: 06-11-2009, 03:56 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