Skip to content

Instantly share code, notes, and snippets.

@IllusiveMilkman
Created November 17, 2020 05:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IllusiveMilkman/22fa5602f3d4c2f2b7b06618b0e1992f to your computer and use it in GitHub Desktop.
Save IllusiveMilkman/22fa5602f3d4c2f2b7b06618b0e1992f to your computer and use it in GitHub Desktop.
VBA Debug Array - Print to Immediate Window
' The following Sub can be used in VBA to print the contents of an Array to the Immediate Window for debugging purposes
Sub DebugPrintArray(arr As Variant)
Debug.Print ("----------------------Debugging Array----------------------")
Debug.Print ("Array row count (from zero): " & UBound(arr))
Debug.Print ("Array col count (from zero): " & UBound(arr, 2))
Dim rowString As String
rowString = ""
For r = 0 To UBound(arr)
rowString = ""
For c = 0 To UBound(arr, 2)
If c = 0 Then
rowString = arr(r, c)
Else
rowString = rowString & "," & arr(r, c)
End If
Next c
Debug.Print (rowString)
Next r
Debug.Print ("----------------------Debug Complete-----------------------")
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment