Option Explicit
Public Name As String, Parent As NamedCollection, Index As Long, Content As Collection
Public Function Add(ByVal Name As String, Optional ByVal Item As Variant) As NamedCollection
If IsMissing(Item) Then Set Item = New NamedCollection
If Content Is Nothing Then Set Content = New Collection
Content.Add Item, Name
If TypeOf Item Is NamedCollection Then
Set Add = Item
Add.Name = Name
Set Add.Parent = Me
Add.Index = Me.Content.Count
If Add.Content Is Nothing Then Set Add.Content = New Collection
End If
End Function
Public Function Item(ByVal Name As String)
On Error Resume Next
If IsObject(Content(Name)) Then Set Item = Content(Name) Else Item = Content(Name)
End Function
Public Sub Delete(Optional ByVal Name As String = "*")
If Name = "*" Then
Parent.Content.Remove Me.Name
Me.Name = "": Index = 0: Set Parent = Nothing
Else
Content.Remove Name
End If
End Sub