Thank you Abousetta!
Though there were minor bugs in the code, I was able to get what you were trying to make me understand. Thank you very much! :D But I must say, the last part..
It still gives the result in 2D array. As I got "Subscript out of range" error when I tried getting the element using dynArr(i) statement.dynArr is now a 1D array because Application.transpose converts the 2D array (the range) to a 1D array
Following is my working code:
![]()
Dim dynArr Sub RangeToArray() dynArr = Application.WorksheetFunction.Transpose(Application.WorksheetFunction.Transpose(Range("Test1"))) For i = 1 To UBound(dynArr) MsgBox "Elements : " & Range("Test1")(i).Address & Chr(13) & dynArr(i, 1) Next i Exit Sub For Each cell In Range("Test1") dynArr(i) = cell.Value MsgBox dynArr(i) & "/" & UBound(dynArr) i = i + 1 Next cell End Sub
Bookmarks