Certified

Board Regular
Joined
Jan 24, 2012
Messages
189
Here is a snippet of my code:
Code:
Set Results = New Dictionary

For i = 2 To UBound(Mainarray)

TheDate = Mainarray(i, 1)


' If team one is not already in dictionary then add
Results.CompareMode = TextCompare

If Results.Exists(TheDate) Then

'Results(TheDate) = Mainarray(Ecount, 1)
Tran.Update_Amount = Mainarray(i, 8) + Tran.Update_Amount

Else
Tran.Update_Amount = Mainarray(i, 8)
Results.Add Key:=Mainarray(i, 1), Item:=Tran.Update_Amount

End If

Next i

What is the syntax to debug.print this code?

Note: The item is a part of a class.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
What exactly are you trying to debug/check?

Instead of Debug.Print have you considered using the Local/Watch windows?
 
Upvote 0
To simply printing the contents of a dictionary to the Immediate window you can use this subroutine:

Code:
Sub DebugDictionary(Dictionary As Object)

Dim Key As Variant
  
  For Each Key In Dictionary.keys
    Debug.Print "Key: " & Key & "; Item: " & Dictionary(Key)
  Next Key
  
End Sub

If you want to read the contents form the watch window you would be best served having the following function in your code and putting "WatchDictionary(Results)" in the watch window in the context of your method.

Code:
Function WatchDictionary(Dictionary As Object) As Variant

Dim Arr As Variant

Dim Key As Variant
Dim x As Long

  ReDim Arr(0 To Dictionary.Count - 1)
  
  For Each Key In Dictionary.keys
    Arr(x) = "Key: " & Key & "; Item: " & Dictionary(Key)
    x = x + 1
  Next Key
  
  WatchDictionary = Arr
  
End Function
 
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,365
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top