联合范围在Excel Interop中

时间:2011-01-14 14:41:35

标签: vb.net excel

我想要一个组合范围。 如何将两个范围合并为一个?

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 '????

1 个答案:

答案 0 :(得分:1)

请参阅此Microsoft知识库文章:15: How to Select the Union of Two or More Specified Ranges

您需要使用Excel.Application对象,然后执行以下操作:

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