+ Reply to Thread
Results 1 to 8 of 8

Dynamic Named Ranges using other cell values

  1. #1
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2007
    Posts
    113

    Dynamic Named Ranges using other cell values

    I am looking for a way to dynamically define named ranges in a sheet that will have rows frequently added/removed.

    I've only included a snippet of the sheet, and a few examples of how I am looking to define the named ranges.

    So, for example, cells G4:G13 should be defined as range "DIV_1".
    Similarly, cells G14:G23 should be defined as range "DIV_2".
    Also, cells G24:G34 should be defined as range "DIV_3".

    The suffixes of 1, 2, and 3 are with respect to the values in Column E.
    The value "DIV" is relative to the value in cell E3.

    As these ranges can extend for several thousands of rows, I am looking for a way to define them via VBA.

    I've found examples of code online that I am having difficulty in adapting to my sheet, so I would be extremely appreciative for any help offered.
    Also as noted above, this is only a snippet, but I would need to similarly define other named ranges based on additional columns -- but if I can see how it works for this sample set of data/columns, I hope to be able to figure out the rest on my own.

    Thanks in advance!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: Dynamic Named Ranges using other cell values

    Div_1
    Please Login or Register  to view this content.
    div_2
    Please Login or Register  to view this content.
    div_3
    Please Login or Register  to view this content.

    the forum lower - cased this, not me. will still work though
    Last edited by Neil_; 09-26-2016 at 12:58 PM.
    Frob first, tweak later

  3. #3
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2007
    Posts
    113

    Re: Dynamic Named Ranges using other cell values

    Neil,

    Thank you for offering this solution.

    I should have been a bit more specific however, as Col G can extend for thousands of rows, and there could be hundreds if not thousands of DIV values as well.

    Per the solution you've provided, it appears that my macro would need to contain every possible one of those contingencies, if I am interpreting the usage of offset(g2, match([x],...) correctly -- where [x] represents the Div numbers?

    If so, I would be really interested in knowing instead if there is a way to automatically leverage whatever values exists in Col E when naming the range, so rather than having separate formulas that have pre-defined values for DIV, just a general way of being able to detect the values in Col E and using those as part of my named range.

    Thoughts?
    Last edited by hamidxa; 09-26-2016 at 02:56 PM.

  4. #4
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: Dynamic Named Ranges using other cell values

    Use a scripting dictionary to get the unique Divs. Loop through the dictionary and use .Find and Union() to define the ranges. Code is on its way...

  5. #5
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2007
    Posts
    113

    Re: Dynamic Named Ranges using other cell values

    Sounds interesting.
    Really intrigued to see what you come up with!

    Thanks again!

  6. #6
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: Dynamic Named Ranges using other cell values

    Please Login or Register  to view this content.
    Edit: added an offset to get the right column.

    Column E doesn't have to be sorted for this to work by the way, but it may throw an error if the named ranges get too complex.
    Last edited by Neil_; 09-26-2016 at 04:30 PM.

  7. #7
    Forum Contributor
    Join Date
    05-24-2012
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2007
    Posts
    113

    Re: Dynamic Named Ranges using other cell values

    Neil,

    This is brilliant! Tested and working.
    Thanks again for sharing your time and solution!

  8. #8
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: Dynamic Named Ranges using other cell values

    You're most welcome!

+ 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] Add two Dynamic Named Ranges in userform combobox1. Show values on label1 from combobox se
    By svgopalareddy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2015, 10:54 AM
  2. [SOLVED] Dynamic Named Ranges
    By BadlySpelledBuoy in forum Excel General
    Replies: 2
    Last Post: 06-14-2013, 05:31 AM
  3. Find/Replace Cell Values with Named Ranges
    By enk529 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2010, 06:07 PM
  4. 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
  5. dynamic named range relating to cell values
    By mark_jam3s in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2008, 06:57 AM
  6. Named ranges by cell values?
    By mikeyfear in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2008, 01:57 PM
  7. Dynamic Named Ranges
    By [email protected] in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 03-09-2006, 11:15 AM

Tags for this Thread

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