And sometimes it's difficult to use 1-based:
<font face=Courier New><SPAN style="color:darkblue">Option</SPAN> <SPAN style="color:darkblue">Base</SPAN> 1
<SPAN style="color:darkblue">Sub</SPAN> TestArr()
<SPAN style="color:darkblue">Dim</SPAN> myArr1 <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Variant</SPAN>, myArr2 <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Variant</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> MyArr3 <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Variant</SPAN>, myArr4 <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Variant</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> myArr5() <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Byte</SPAN>, myArr6 <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Variant</SPAN>
<SPAN style="color:darkblue">Let</SPAN> myArr1 = Array(1, 2, 3)
<SPAN style="color:darkblue">Let</SPAN> myArr2 = [{1,2,3}]
<SPAN style="color:darkblue">Let</SPAN> MyArr3 = [transpose(transpose(a1:c1))]
<SPAN style="color:darkblue">Let</SPAN> myArr4 = [transpose(a1:a3)]
<SPAN style="color:darkblue">Let</SPAN> myArr5 = StrConv("1,2,3", vbFromUnicode)
<SPAN style="color:darkblue">Let</SPAN> myArr6 = Split("1|2|3", "|")
<SPAN style="color:darkblue">Debug</SPAN>.<SPAN style="color:darkblue">Print</SPAN> <SPAN style="color:darkblue">LBound</SPAN>(myArr1)
<SPAN style="color:darkblue">Debug</SPAN>.<SPAN style="color:darkblue">Print</SPAN> <SPAN style="color:darkblue">LBound</SPAN>(myArr2)
<SPAN style="color:darkblue">Debug</SPAN>.<SPAN style="color:darkblue">Print</SPAN> <SPAN style="color:darkblue">LBound</SPAN>(MyArr3)
<SPAN style="color:darkblue">Debug</SPAN>.<SPAN style="color:darkblue">Print</SPAN> <SPAN style="color:darkblue">LBound</SPAN>(myArr4)
<SPAN style="color:darkblue">Debug</SPAN>.<SPAN style="color:darkblue">Print</SPAN> <SPAN style="color:darkblue">LBound</SPAN>(myArr5)
<SPAN style="color:darkblue">Debug</SPAN>.<SPAN style="color:darkblue">Print</SPAN> <SPAN style="color:darkblue">LBound</SPAN>(myArr6)
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN></FONT>
One reason to not even bother mucking with the declaration, simply use LBound.
XLD said:
There shouldn´t be a need to check the LBound for arrays if we know the basic about arrays in XL.
There are so many ways to stack an array with VBA, and the results vary to such an extent that LBound & UBound are tremendous tools!
I can certainly see a need to check the boundaries and it's hard to see why there would be any shame in using them, besides, like Colt 45, they work every time (including the previous example)!