SOLVED: I didn’t realize that: oRange.getDataArray() does NOT return a 2D array, but a single column array of arrays.
I have tried every variant of
If CStr(arr(i)) <> ""
arr(i) <> ""
----------------------------
If VarType(arr(i)) = vbString Then
If arr(i) <> "" Then
I have verified the array is fine.
If Not IsEmpty(arr(i)) And Not IsNull(arr(i)) Then
If CStr(arr(i)) <> "" Then 'all version error:Object variable not set
'msgbox arr(i)
If arr(i) <> "" Then
tempArray(j) = arr(i)
j = j + 1
End If
Else
tempArray(j) = arr(i)
j = j + 1
End If
End If
Here is the code that loads the array:
Function ReadCellsIntoArray(cellName As String, oSheet As Object) As Variant
Dim oRange As Object
Dim dataArray As Variant
oRange = oSheet.getCellRangeByName(cellName)
dataArray = oRange.getDataArray()
ReadCellsIntoArray = dataArray
End Function