Use Array.Copy()
Dim arrayData(,) As Double
Dim objData(,) As Object = currentSheet.Range("A2").Resize(maxRow - 1, 2).Value
Array.Copy(objData, arrayData, objData.Length)
By the way I found this by putting convert 2d object double
into a search engine...
How can I quickly up-cast object[,] into double[,]?
Edit
I just tried it on my own Excel sheet and it works. One thing I should add is that I needed to specify the bounds of the destination array when dimensioning it.
'Dim objData(,) As Object = xlSheet.Range("C6:E14").Value ' either way works
Dim objData(,) As Object = xlSheet.Range("C6").Resize(9, 3).Value
Dim dblData(objData.GetUpperBound(0) - 1, objData.GetUpperBound(1) - 1) As Double
Array.Copy(objData, dblData, objData.Length)
Can you inspect your Object(,)
at runtime to make sure there is data inside it? Also, everything needs to be castable to Double
.