I'm trying to accomplish this obviously simple thing, but somehow VBA keeps serving me weird errors. I would like to have a global array named styles containing the following strings: Settings, Titles, Comment and Direct Copy. in Code:
Public styles(4) As String
Directly assigning the array was not working for me so i did this via a sub:
sub Populate()
styles(0) = "Settings"
styles(1) = "Titles"
styles(2) = "Comment"
styles(3) = "Direct Copy"
Debug.Print styles
End Sub
However this does not work as it gives a compile error: Type mismatch on the debug.print line... The expected result was something like: ("Settings", "Titles", ..) etc like any programming language would return.
So how do I get a public array containing strings in VBA Excel such that I can use them in the same module across functions and subs?
Debug.Print styles(0)...Debug.Print styles(1)....Debug.Print styles(2)....Debug.Print styles(3).....