Single Dimension Array with OptionBase 1 or 0
Option Base 1
Public SH As Worksheet
Function InputWorksheet()
Set SH = ThisWorkbook.Sheets("InputData")
End Function
Sub Create_SingleDimension_Array_Optionbase_1()
Dim SingleDim(5) As String
InputWorksheet
For r = 1 To 5
SingleDim(r) = SH.Range("A" & r).Value
Next
MsgBox LBound(SingleDim)
MsgBox UBound(SingleDim)
For i = LBound(SingleDim) To UBound(SingleDim)
MsgBox SingleDim(i)
Next
End Sub
'=========================
Sub Create_SingleDimension_Array_Optionbase_0()
Dim SingleDim(5) As String
InputWorksheet
For r = 0 To 5
SingleDim(r) = SH.Range("A" & r + 1).Value
Next
MsgBox LBound(SingleDim)
MsgBox UBound(SingleDim)
For i = LBound(SingleDim) To UBound(SingleDim)
MsgBox SingleDim(i)
Next
MsgBox SingleDim(0)
MsgBox SingleDim(1)
MsgBox SingleDim(2)
MsgBox SingleDim(3)
MsgBox SingleDim(4)
MsgBox SingleDim(5)
End Sub