I am creating an arrays from a range of cells in Excel. All works, array is created. The problem is i use "Option Base 0" and all my other arrays are (0 to x), but arrays created by reading a range are (1 to x+1). Is there any way to read an Array from a range with first element with number 0?
Sample code:
Sub ArraysFromRange()
Dim myArray(9) As Integer, myArray2() As Variant
Dim i As Integer
Dim rngTarget As Range, rngTarget2 As Range
Range("A1:M20").Clear
For i = 0 To UBound(myArray)
myArray(i) = i
Next i
With ThisWorkbook.Worksheets("test")
Set rngTarget = .Range(.Cells(1, 1), .Cells(UBound(myArray) + 1, 1))
Set rngTarget2 = .Range(.Cells(1, 2), .Cells(UBound(myArray) + 1, 2))
End With
rngTarget = Application.Transpose(myArray)
myArray2 = Application.Transpose(rngTarget)
End Sub
After this i have two arrays, but first one is (0 to 9) and second one (1 to 10). If i have a lot of arrays in code i must always remember which one shall have index - 1.
Question two: is there any possibility to read an array from a range as a "Boolean" or "Integer" instead of "Variant"?