Public Function UnionRange(ParamArray CellRanges() As Range) As Range
Dim ExcelApp As Microsoft.Office.Interop.Excel.ApplicationExcelApp = ExcelDnaUtil.ApplicationDim FinalRange As Range = Nothing For Each R As Range In CellRanges FinalRange = ExcelApp.Union(FinalRange, R) Next Return FinalRange End Function
VBA Sub that calls ExcelDNA Add-In
Sub UNO()Dim A As Range, B As Range, C As RangeSet A = Range("A1:A5")Set B = Range("H18:Z18")Set C = VBA.UnionRange(A, B)MsgBox C.AddressEnd Sub
It could be that ParamArray is not supported by the .NET / COM interop.
Just make the parameter an array, and always pass it that way from VBA.
-Govert
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.