Created
November 17, 2020 05:32
-
-
Save IllusiveMilkman/22fa5602f3d4c2f2b7b06618b0e1992f to your computer and use it in GitHub Desktop.
VBA Debug Array - Print to Immediate Window
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' 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