Private Sub cjList() ' use cjobject to get a unique list Dim a As Variant, cj As New cJobject, j As cJobject, i As Long a = Array("a", "b", "c", "c", "d", "d", "e", "a") With cj.init(Nothing) For i = LBound(a) To UBound(a) .add CStr(a(i)) Next i End With For Each j In cj.children Debug.Print j.key Next j End Sub
Even, better, cJobject can organize things into families.
Private Sub cjListFamily() ' use cjobject to get a unique list Dim a As Variant, cj As New cJobject, j As cJobject, i As Long, jj As cJobject a = Array("smith.john", "smith.mary", "jones.fred", "jones.tom", "white.chalky", "smith.tom") With cj.init(Nothing) For i = LBound(a) To UBound(a) .add CStr(a(i)) Next i Debug.Print .formatData End With End Sub
1.smith
1.smith.john
1.smith.mary
1.smith.tom
1.jones
1.jones.fred
1.jones.tom
1.white
1.white.chalky
See How to use cJobject for more on this useful object.
Take a look at One Liners for more tips like this.
In the meantime why not join our forum, follow the blog or follow me on Twitter to ensure you get updates when they are available. You can download this example in the cDataSet.xlsm from Downloads
bruce mcpherson is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Based on a work at http://www.mcpher.com. Permissions beyond the scope of this license may be available at code use guidelines