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. Download our free add-in to quickly insert any of the sample code found on our site into the Visual Basic Editor.

alt text

Stop searching for VBA code online. Try the Code VBA Add-in…

Free Download!

<<Return to VBA Examples

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