Iterate over a possibly empty array in VBA (Excel)
When you try to iterate over an empty array in VBA like this, you will get a runtime error (index out of bounds): Sub ArrayTest() Dim testarray() As Integer Dim i As Integer For i = LBound(testarray) To UBound(testarray) ‘ <– error Debug.Print testarray(i) Next i End Sub Even if…