ozgur
ozgur

Reputation: 21

Union ranges in Excel Interop

I want a combined Ranges. How do I combine two ranges into one?

Dim range1 as Excel.Range =   osheetTemperatureData.Range("A7:"A10")
Dim range2 as Excel.Range =   osheetTemperatureData.Range("C7:"C10")

Dim range3 as Excel.Range = range1 + range2 '????

Upvotes: 2

Views: 3709

Answers (1)

MicSim
MicSim

Reputation: 26796

See this Microsoft KB article: 15: How to Select the Union of Two or More Specified Ranges

You need to use the Excel.Application object and then do something like:

Dim range3 as Excel.Range = xlApp.Union(range1, range2)

Upvotes: 3

Related Questions