I work with double array which are partially filled with data and then printed to a range in a n excel sheet.
The problem is, that all values are by default 0. I would want them to be NaN (not a number), which is represented in the cells as NV(). The double array should convert to NV() automatically if possible.
Instead of declaring your Array as double just maintain it as variant
Then you can initialize the Array with
#NA using CVErr(xlErrNA)
Sub MyInitializer() Dim Arr(10) 'Initialize all values to #NA For i = 0 To UBound(Arr) Arr(i) = CVErr(xlErrNA) Next 'Do something with Arr values Arr(1) = 2.5 Dim Destination As Range Set Destination = Range("K1") Set Destination = Destination.Resize(UBound(Arr), 1) Destination.Value = Application.Transpose(Arr) End Sub