I'm looping through a named range and appending an array based on if the cell is empty or not. I'm not too familiar with arrays in VBA, so perhaps my logic is incorrect. The code keeps overwriting the 1st element in the array and it never gets incremented. I"m not sure why the UBound(myArray) always stays at 0 even after an element has been assigned to the 1st index.
My code looks something like:
Dim myArray() As Double
ReDim Preserve myArray(0)
For Each cell In [myRange]
If cell <> "" Then
If UBound(myArray) > 0 Then
ReDim Preserve myArray(0 To UBound(myArray) + 1)
End If
myArray(UBound(myArray)) = cell.value
End If
Next