Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://excelmacromastery.com/vba-dictionary/

Create Dic:

Public MyDic As Object   
Public Sub TestDic()
Dim k, tmp As String

 Set  MyDic = CreateObject("scripting.dictionary")
 For Each rcell In Rng.Cells
  tmp = Trim(rcell.Value)
  'If Len(tmp) > 0 Then  MyDic (tmp) =  MyDic (tmp) + 1
   If Len(tmp) > 0 Then  MyDic .Add Key:=tmp, Item:=rcell.Offset(0,1).Value
 Next c

 For Each k In  MyDic.keys
  Debug.Print k,  MyDic (k)
 Next k

End Sub

Remove:

dict.Remove Key


Add:

dict.Add Key:="Orange", Item:=45
  • No labels