Results 1 to 7 of 7

Union named Ranges

Threaded View

  1. #1
    Registered User
    Join Date
    03-15-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2003
    Posts
    37

    Union named Ranges

    (Using Office 2003 on XP Pro) I have two named ranges that I want to union into one big named range so that I can use the big named range in a validation table. Unfortunately the big range does not appear on the list of named range so I switched to VBA to try and lick this but really I was hoping a non-VBA solution exists. Exploring possible VBA solutions, here is what I have so far:
    Private Sub Worksheet_Activate()
    'Sheet2 is active
    Sheets("Sheet1").Select 'this is where the data is located
    Dim BigRange As Range
    Set BigRange = Union([A2:A65536], [B2:B65536])
    ActiveWorkbook.Names.Add Name:="AllEvent", RefersTo:=BigRange
    
    End Sub
    This code works and BigRange is created but when I attempt to use it in a validation table an error states that the range is not contiguous (or something to that effect.).

    Notice I used a worksheet ACTIVATE event. The validation is on Sheet2, the data for columns A & B are on Sheet1, by using the ACTIVATE event the code will refresh BigRange each time Sheet2 is activated which is necessary since the data on sheet1 can be changed at anytime.

    Back to a non-VBA solution, I tried to concatenate two named ranges in the "source:" field of data validation dialog. I tried to input: =SmallRange1, SmallRange2 and excel reported this was no good and to use a delimiter but I cannot determine what the correct delimiter is. If a delimiter works then this would be a preferred solution over a VBA solution.

    If there is no straightforward solution then I plan to write a VBA solution that builds one contiguous list from columns A and B and then saves a named range from that. But I want to hold off and see if anyone has a nicer solution.

    Thanks for taking the time to read this!
    Last edited by MrHockey; 05-13-2009 at 03:11 PM.

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