How to print two dimensional array in Immediate window in VBA ? Does it exist any generic method for doing this ? Some method for ploting one row of array per line in Immedi
paste below data in column A(Name ) in column B (Age)
Name Age
A 10
B 20
C 30
D 40
E 50
F 60
G 70
and run the below code
Sub Array_Demo()
Dim arr() As String
Dim i As Integer, j As Integer
' fill the array with strings
Last = Range("A" & Rows.Count).End(xlUp).Row
ReDim arr(Last, 1)
For i = 0 To Last - 1
arr(i, 0) = Cells(i + 1, 1).Value
arr(i, 1) = Cells(i + 1, 2).Value
Next
' only one loop to display its contents !!!
Dim v As Variant
For Each v In arr
Debug.Print v
Next
End Sub
You can see the below output in Immediate window
Name
A
B
C
D
E
F
G
Age
10
20
30
40
50
60
70