Alternative use of Array () function in VBA?
We usually use VBA array function like:
Dim A As Variant
A = Array("B", 1)
This will give me the first item in as "B" and the second item as 1
However, I want to resolve the content of A at runtime, so that it is possible for me to do something like
Dim str As String
Dim A As Variant
str = "name, Sam"
A = Array(str)
When I run this code, it gives me the first element in A
as "name, Sam"
, but I need the first element as "name"
and the second as "Sam"
.
What could be the solution to this? How can I fill A
in at runtime?
+2
source to share