Normally we code a range by writing it within "" as under
Range("A1:A10").SelectHowever if you put , between multiple ranges within the same line of the code you can select multiple ranges as given under
How to use Multiple Ranges in Excel VBAFollowing macro code will explain you how to use multiple ranges in Excel VBA
MsgBox ("Single Range Selected")
MsgBox ("Multiple Ranges Selected")
In the above macro we have selected range three different ranges
After selection we have copied the contents to Range A11. Another option for doing this was to copy the contents one by one for each of the range. However copy and paste is only one of the example you can use this for any desired action by you.
You can combine multiple ranges into one Range object using the Union method.
The following example creates a Range object called myMultipleRange, defines it as the ranges A1:B2 and C3:D4, and then formats the combined ranges as bold.