Hi Skip,
I am not sure if I understand your suggestion.
What I would like to do is to generate one Excel file that holds all my different hirachies in named ranges, and I can promise there are many ranges...
The ranges hold the hirachy in two columns: first colum parent, secondcolumn child.
In order to have my data somewhat organised I will name my ranges as follows: [LibaryName].[DimensionName]
A "libary" would represent one or more "datadump file" depending if they use the same dimensions. The dimension name would be for example "base product codes" - that will get a product group hirachy (comes from the named range).
Examples for those could be:
SalesReport.ProductCodes
SalesReport.SalesStaff
SalesReport.Stores
Stockreport.ProductCodes (these codes could be potentially a different syntax than in SalesReport.ProductCodes)
Common.Period (this would be for dimension that are common in all data dumps)
My listboxes on the user form will only hold the libary and dimendsion info (to keep the overview): There will be one listbox hardcoded that shows all the libary names (SalesReport, StockReport, Common,...). Once you click this one (with an easy ..._click procedure

) you get a listbox that shows the dimensions related to that libary. Ie. you click "Salesreport" in the first listbox, it unhides the second list box which shows: ProductCodes, SalesStaff and Stores. Since I never know how many different libaries I will make (in the next 20 years....

), I am generating this "second visibile" (actually many as it is one listbox per dimension at run time when the form is initalised (loaded). But I am hiding all the listboxes that hold the dimensions of the non-selected libaries from the first listbox.
The trick comes now: If you click (and thats what my problem is...) a dimension in the second listbox, it will show a treeview with the hirachy roll-up of the dimension. These treeviews are also generated at run time, one per "Libary.Dimension".
All of above I have running prefectly except this "bloody" click on the second at runtime generated listbox...
I have tested combos FAQ tip, which works great with the command buttons, but I don't get it running with the Listboxes.
I have modified his code as follows:
On the frmCol userform module I have added two listboxes LB1 & LB2 hardcoded for first testing - but that is where it gets stuck already:
Private colCB As New Collection
Private ctlCB As cCB
Private Sub UserForm_Initialize()
Set ctlCB = New cCB
ctlCB.Init LB1, Me
colCB.Add ctlCB
Set ctlCB = New cCB
ctlCB.Init LB2, Me
colCB.Add ctlCB
End Sub
Public Sub Info(ctl As MSForms.ListBox)
MsgBox "click by: "
End Sub
and on the classmodule cCB:
Private WithEvents m_CB As MSForms.ListBox
Private m_Form As frmCol
Public Sub Init(ctl As ListBox, frm As frmCol)
Set m_CB = ctl
Set m_Form = frm
End Sub
Private Sub m_CB_Click()
m_Form.Info m_CB
End Sub
Private Sub Class_Terminate()
Set m_CB = Nothing
Set m_Form = Nothing
End Sub
Maybe combo knows help????
Thanks,
Axel