Use Static or ReDim to dimension arrays in this procedure
You are trying to use Dim To create a fixed array, use Dim at the module level or Static at the procedure level. You may also choose to create a dynamic array at the procedure level using ReDim . to create a fixed array (an array having a specific number of elements) at the procedure level .
Arrays created with Static are persistent arrays whose values are kept in memory after the procedure is finished running. Procedure-level dynamic arrays are released automatically at procedure exit.