After some trial and error I got the code working
Public Function GetRange1() As Double()
Dim rows As Integer
Dim MyRange As Double()
MyRange = Nothing
Try
'Dim selection As ExcelReference = CType(XlCall.Excel(XlCall.xlfSelection), ExcelReference)
'Read example
Dim sheet1 As ExcelReference = CType(XlCall.Excel(XlCall.xlSheetId, "Sheet1"), ExcelReference)
Dim source As New ExcelReference(7, 15, 3, 3, sheet1.SheetId)
'Dim SelectionContent As Object = source.GetValue()
Dim OffsetRef As Object = XlCall.Excel(XlCall.xlfOffset, source, 4, 0, 6)
Dim SelectionContent As Object = OffsetRef.GetValue()
Dim values1 As Object(,) = CType(SelectionContent, Object(,))
rows = values1.GetLength(0)
ReDim MyRange(rows - 1)
For i As Integer = 0 To rows - 1
Try
MyRange(i) = CType(values1(i, 0), Double)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
GetRange1 = MyRange
End Function
Op donderdag 31 augustus 2023 om 15:30:24 UTC+2 schreef Bart: