Now this could sound very silly as it looks very simple but I am not able to understand the way how to declare a single dimension array that can take strings from a range as values. Here is what I am trying to do.
Sub myArr()
Dim V(1 To 2) As String
V(1) = "Hello"
V(2) = "World"
'V = Range("A1:A2").Value 'What is wrong in this syntax?
End Sub
I have two strings "Hello" & "World" in range A1:A2. I searched for it and saw some articles where loops were written to get all the string values in the range into an array of string type. How can I get this into an array in a single line syntax. Is there a way to do it? Please help.
EDIT : for better explanation
I am looking for a 1D array and wanted to check if there is a single line code that can put range values in the array which should be of type string without having to loop its elements. I have updated my question. Kindly have a look at it.
If I loop through the elements, I would get something like this

But I am looking for string type values like below with a one liner code

Range("A1:A2").Valuewill return a 2 dimensional array. What are you looking for ?Dim v, thenV = Range("A1:A2").Valuewill return a 2D array and you can use its elements asDebug.print V(1,1), V(2, 1). Is it a need to be 1D?Variant. As I tried showing in my previous comment.