Merging two excel named ranges into one

kdshaw01

New Member
Joined
Oct 17, 2011
Messages
11
Hello,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
I have been reading several thread about using the Union Method to merge two ranges into one, but I have not been able to successfully get mine to work. I read about issues with nulls, but fail to understand the issue. <o:p></o:p>
<o:p></o:p>
Here is what I have. Both ranges contain only text values with the exception of the trailing cells. I have tried removing the trailing cells to see if the union would work with no success<o:p></o:p>
<o:p></o:p>

Named Range Alpha is defined from A1 to A66. <o:p></o:p>
Cell A66 is blank.
<o:p></o:p>

Named Range Beta is defined from B5 to B25.<o:p></o:p>
Cell B25 is blank.<o:p></o:p>
<o:p></o:p>

When I run the step below in vba, the new named range is created, but contains nothing.<o:p></o:p>
<o:p></o:p>

ActiveWorkbook.Names.Add Name:="CombinedRoadmapFiles", RefersTo:=Union(Range("Alpha"), Range("Beta"))<o:p></o:p>
<o:p></o:p>

If I replace Beta with Alpha as shown below, the Alpha range is populated in the new named range. <o:p></o:p>
<o:p></o:p>

ActiveWorkbook.Names.Add Name:="CombinedRoadmapFiles", RefersTo:=Union(Range("Alpha"), Range("Alpha")).


Any advice is greatly appreciated.
<o:p></o:p>

Kind Regards,<o:p></o:p>
<o:p></o:p>
Kieran Shaw<o:p></o:p>
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
When I run your code, I accurately get the combined Range as intended. What exactly are you trying to do with the range that is not working?
 
Upvote 0
I am trying to use the new combined range in a form field as a drop down. As I respond, I realize that I need to add additional details; my apologies. In the Excel Name Manager, I do see the new range and the explicate cell ranges from both Alpha and Beta. It is when I plug the new range into the form.field's RowSource = "'Data'!CombinedFiles" and I run the form. When I open the drop down field, the field is empty.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
..<o:p></o:p>
frmInsertProductDetailRow.fldCurrentProgramFileNamesList.RowSource = "'Data'!CombinedFiles"<o:p></o:p>
frmInsertProductDetailRow.fldCurrentProgramFileNamesList.Style = fmStyleDropDownList<o:p></o:p>
..<o:p></o:p>
 
Upvote 0
I'm going to close this thread. I figured out what was happening. The Union was working correctly as verified by Board member BiocideJ. Thank you. The root cause was that a form field’s row source property does not accept joined ranges; even if one uses a named range created from a union of named ranges. I believe that Excel breaks the named range back down to its definition at run time.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
RowSource = 'Sheet1'!$A$4:$A$49,'Sheet1'!$B$14:$B$58.<o:p></o:p>
<o:p></o:p>
My work around was to manually create a single named range from the two named ranges by looping through both ranges and populating a new set of cells and then creating a third name range based on the new data set. <o:p></o:p>
<o:p></o:p>
I hope this may help someone and or someone may clarify any misunderstandings that I may have.<o:p></o:p>
<o:p></o:p>
Thanks,<o:p></o:p>
<o:p></o:p>
Kieran Shaw<o:p></o:p>
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top