+ Reply to Thread
Results 1 to 9 of 9

Making Size of Named Ranges Adapt

  1. #1
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Making Size of Named Ranges Adapt

    I have an input worksheet into which I occasionally need to insert or delete rows. Any range defined in this sheet grows or shrinks accordingly, which is fine. However, on another sheet that reads from this input sheet, existing named ranges or defined ranges do not grow or shrink to match, so fomulae elsewhere that require ranges to be of the same size fail as soon as I add or delete rows on the input sheet. How can I make ranges on the related sheet grow or shrink automatically to match the input sheet? If this is not possible, how do I assign a fixed size to ranges and named ranges that will not respond dynamically?
    Last edited by AliGW; 03-24-2016 at 06:05 PM.
    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.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Making Size of Named Ranges Adapt

    Hi Ali,

    it must be school holidays again !!

    Are you saying that you don't want to use a dynamic named range, or are you asking for advice on how to set one up?

    Pete

  3. #3
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Making Size of Named Ranges Adapt

    Neither! Yes, it's the school holidays again!!!

    The workbook is complex and full of sensitive data, so I can't easily provide an example, but here's how it works:

    1. Worksheet A is the input sheet. Range $A$4:$A$200 is used in formulae on different sheets. This dynamically changes if I insert or delete a row. So far, so good.
    2. Worksheet B draws data from worksheet A and other worksheets, and it has named ranges (e.g. Gender) that correspond in size to the range mentioned in Worksheet A, but these named ranges do not grow and shrink when I add or delete rows in Worksheet A, even though the data in that sheets appears as it should.
    3. Worksheet C contains formulae (e.g. COUNTIFS) that require the ranges defined to be the same size. These ranges are drawn from Worksheets A and B. Because of 2 above, as soon as I do 1 above, the formulae in this third sheet fail.

    How do I make the ranges or named ranges in Worksheet B grow or shrink when I add or delete rows in Worksheet A?

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Making Size of Named Ranges Adapt

    Well, if you are using COUNTIFS (or SUMIFS, SUMIF, COUNTIF etc.) then you can use full-column references without any fall-off in performance, as those formulae are intelligent enough to make use of the used range, and that will overcome your problem.

    However, if you have SUMPRODUCT or array formulae (entered with CSE) then the performance will be affected, as those will examine every cell in the range.

    Hope this helps.

    Pete

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Making Size of Named Ranges Adapt

    Not sure if this meets your need .

    RngA on Sheet1

    =OFFSET(Sheet1!$A$2,0,0,COUNTA(Sheet1!$A:$A)-1)

    RngB on Sheet2

    =OFFSET(Sheet2!$A$2,0,0,COUNTA(Sheet1!$A:$A)-1)

    As RngA is added to/ or rows deleted, RngB in DV only shows list of length of RngA although more data could be present in column A of Sheet2.

  6. #6
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Making Size of Named Ranges Adapt

    Thanks, John. Are you suggesting that I use these to define the named ranges?

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: Making Size of Named Ranges Adapt

    Yes, John is suggesting that you set up these as dynamic named ranges - note that the first one (on Sheet1) is defined using column A of Sheet1 and the second one (on Sheet2) is also defined using column A of Sheet1, so they should be the same size.

    I thought when you said "Neither" that you didn't want to use dynamic named ranges (as, with OFFSET being a volatile function, they will affect overall performance of the workbook).

    Pete

  8. #8
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Making Size of Named Ranges Adapt

    Thanks, Pete. I think I will go with your solution. I'm currently away from my PC, but will try it later.

  9. #9
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Making Size of Named Ranges Adapt

    You might want to consider using these Dynamic Named Ranges. They use INDEX/COUNTA rather than OFFSET. INDEX is NOT volatile.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Note that both use the count of cells on Sheet1. Bear in mind that these formulae will return the wrong range address if there are spaces in the range.

+ 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] VBA creates named ranges, but named ranges disappear
    By BrotherNeptune in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-05-2015, 03:22 PM
  2. Replies: 3
    Last Post: 01-14-2015, 05:22 AM
  3. Define only 2 named ranges from a list of named ranges...
    By abhi900 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-29-2014, 04:20 AM
  4. Looping Mutliple Named Resized Ranges in next empty row below another named range
    By gingumdog in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2014, 08:15 PM
  5. spreadsheet to adapt to window size
    By wilwhiting in forum Excel General
    Replies: 5
    Last Post: 08-05-2008, 08:32 AM
  6. [SOLVED] Look up function-adapt to fit your real ranges
    By Peo Sjoblom in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  7. Help to adapt Formula syntax to work with Dynamic Named Ranges
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 04-28-2005, 08:06 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