Can the array variable values persist when macro finishes? I have declared a global variable:
Option Explicit
Public Arr2D As Variant
Public Sub ReadDataToArr()
Arr2D = [MyNamedRange].Value
End Sub
but as soon as the macro finishes then Arr2D becomes out of context and Arr2D gets empty. I would like to read data to all array variables as Workbook opens and use them on whatever occasion I want without declaring and filling them every time.
Update. Why do I think it is empty? Add a Watch for Arr2D variable.
When I am in debug mode of macro above (hitting F8) I see this:

When I come with F8 hits to the macro end then I see this:

Update again. I noticed something strange to me. When I run the above macro second time in debug mode (after initializing values, and after the variable got out of context), then immediately in the very first line of the macro, the variable becomes "filled" with values, and in the context. So maybe that is why disagreement in comments arouse.
Module1.ReadDataToArrso of course if you exitReadDataToArrthat context is invalid. But you just watch on the wrong context, the variable and its data persists. Proof: Add another sub and putDebug.Print Join(WorksheetFunction.Transpose(Arr2D), ",")into it then run firstReadDataToArrthen the other sub.