Dear Santek Brenner
Thank you for posting your question in the Microsoft Q&A forum.
To make your VBA code work cross‑platform (Mac & Windows) without complex workarounds, you can simply replace the Scripting.Dictionary with the native VBA Collection object.
Please test the following code and let me know if it meets your requirements:
Sub CountItems()
' Use "New Collection" instead of CreateObject to work on Mac
Dim coll As New Collection
' IMPORTANT: Collection.Add syntax is reversed compared to Dictionary
' Dictionary: .Add Key, Value
' Collection: .Add Value, Key
coll.Add 1, "Apple"
coll.Add 2, "Orange"
MsgBox "Total items: " & coll.Count
End Sub
If this solution doesn’t fully address your needs, please share your feedback so I can assist further.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.