Hi there,
Sorry for my Noobness with Excel/Vba... coming from a unix world...I need help!
I am trying to build a TreeView in an Excel Form from an excel Sheet with 3 columns. The sheet references a list of cinemas, already organized in a "tree view", where the A Column refers to a cinema group name, the B and C columns refer to the particular cinema names and infos, for example:
A1:Independent Cinemas
B2:CinemaName1 C2:Cinema1 Infos
B3:CinemaName2 C3:Cinema2 Infos
B4:CinemaName3 C4:Cinema3 Infos
A5:Cineplex Cinemas
B6:CinemaName4 C6:Cinema4 Infos
B7:CinemaName5 C7:Cinema5 Infos
A8:Next Group of Cinemas
B9:..... etc etc
Following this description, I want the treeview to look like:
+-A1
---+B2,C2
---+B3,C3
---+B4,C4
+-A5
---+B6,C6
---+B7,C7
+-A8
---+B9,C9
etc...
Sorry for the representation its lame but you get the picture... Here is what I have so far:
Private Sub TreeView_Populate()
Dim wbBook As Workbook
Dim wsZones As Worksheet
Dim rngZones As Range
Dim lngRows As Long
Set wbBook = ThisWorkbook
Set wsZones = wbBook.Worksheets("Cinemas")
lngRows = wsZones.Range("A65536").End(xlUp).row
Set rngZones = wsZones.Range("A1:A" & lngRows)
Dim lElement As Long
Dim rCell As Range
With Me.ZonesTree.Nodes
'Clear TreeView control
.Clear
For Each rCell In rngZones
'We have a group name in the A columns so we attach it to the tree
If Not rCell.Text = "" Then
.Add Key:=rCell.Text, Text:=rCell.Text
'THIS IS WHERE I BLOCK!!
'Need the range from Columns B and C until the next Value in the A Column
'in order to add the children nodes....
.Add relative:=CinemaName, _
relationship:=tvwChild, _
Key:=CinemaName(here it will be B column), CinemaInfos(C column)
Text:=CinemaName(B column)
End If
Next rCell
End With
End Sub
I also have .ZonesTree.LineStyle = tvwRootLines in my form initialize sub-routine, which create check boxes for each element of the tree. I would like all the check boxes to be selected by default...
Is this feasible? I basically need a "temporary" range containing the values from B et C columns to build the children nodes... In the vba code I added some comments to where Im failing... All help/suggestion will be greatly appreciated!