VBA Union – Join Multiple Ranges

Associated Files Download Links

Union – Join Multiple Ranges

You might want to combine or join multiple ranges if the range string is too long, or you want to attempt to make your code easier to work with.
The need to combine multiple range strings is probably most common when selecting a large number of non contiguous cells with VBA.
One way to join multiple range strings is using VBA’s Union function. The syntax for the Union function is:

The following is an example of using Union. First you declare some range variables, then set the range variables equal to something, and finally combine them using Union.

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!

alt text

Learn More!

<<Return to VBA Examples

Did you find this VBA tutorial useful? Then share it with your friends and colleagues:

You may also like some of this related content...

We have already gone over what variables and constants are, in our VBA Data Types
Select All Cells In Worksheet with .Cells To select all the cells on a sheet
Change Cell Background Color with Interior.colorindex To change a cells background color using VBA you
UsedRange - Find Last Used Cell, Column or Row The following code will return in
The standard Excel “Column” Function returns the number rather than the letter of the column
Automate Excel
Left Menu Icon