VBA: List view problem, where's the mistake?

F

furbiuzzu

i've written this code to obtain a list view but i cannot visualize all
data contained in my list.
everytime i launch my macro i get an "1004 run time error", i can't
understand why.
(surely because my lack of knowledge about list view & tree view
features).

the structure i want to obtain is very simple, here follow a little
scheme

A
A1
A2
..
..
..
A14
A15
B
B1
B2
..
..
..
B14
B15

etc etc etc

Actually i can visualize only 10 of my 15 categories... is this a
limitation of list view or there's someting wrong in my code...... ???

this is what i've written

Private Sub UserForm_Initialize()
Dim player1 As String
Dim player As String

With TreeView1.Nodes
.Clear
' player1 = Worksheets("team").Range("H3").Value
player1 = "Team"
.Add , , "KEY_1", player1

For i = 4 To 25
player = Worksheets("team").Range("H" & i - 1).Value
'
' add other "father-nodes"

.Add "KEY_" & i - 3, tvwNext, "KEY_" & i - 2, player
'
' add "child nodes"

.Add "KEY_" & i - 2, tvwChild, "KEY_A" & i - 2,
Worksheets("team").Range("W2").Value & ": " &
Worksheets("team").Range("W" & i - 1).Value
.Add "KEY_" & i - 2, tvwChild, "KEY_B" & i - 2,
Worksheets("team").Range("X2").Value & ": " &
Worksheets("team").Range("X" & i - 1).Value
.Add "KEY_" & i - 2, tvwChild, "KEY_C" & i - 2,
Worksheets("team").Range("Y2").Value & ": " &
Worksheets("team").Range("Y" & i - 1).Value
.Add "KEY_" & i - 2, tvwChild, "KEY_D" & i - 2,
Worksheets("team").Range("Z2").Value & ": " &
Worksheets("team").Range("Z" & i - 1).Value
.Add "KEY_" & i - 2, tvwChild, "KEY_E" & i - 2,
Worksheets("team").Range("AA2").Value & ": " &
Worksheets("team").Range("AA" & i - 1).Value
.Add "KEY_" & i - 2, tvwChild, "KEY_F" & i - 2,
Worksheets("team").Range("AB2").Value & ": " &
Worksheets("team").Range("AB" & i - 1).Value
.Add "KEY_" & i - 2, tvwChild, "KEY_G" & i - 2,
Worksheets("team").Range("AC2").Value & ": " &
Worksheets("team").Range("AC" & i - 1).Value
.Add "KEY_" & i - 2, tvwChild, "KEY_H" & i - 2,
Worksheets("team").Range("AD2").Value & ": " &
Worksheets("team").Range("AD" & i - 1).Value
.Add "KEY_" & i - 2, tvwChild, "KEY_I" & i - 2,
Worksheets("team").Range("AE2").Value & ": " &
Worksheets("team").Range("AE" & i - 1).Value
.Add "KEY_" & i - 2, tvwChild, "KEY_J" & i - 2,
Worksheets("team").Range("AF2").Value & ": " &
Worksheets("team").Range("AF" & i - 1).Value
' .Add "KEY_" & i - 2, tvwChild, "KEY_K" & i - 2,
Worksheets("team").Range("I2").Value & ": " &
Worksheets("team").Range("I " & i - 1).Value
' .Add "KEY_" & i - 2, tvwChild, "KEY_L" & i - 2,
Worksheets("team").Range("S2").Value & ": " &
Worksheets("team").Range("S" & i - 1).Value
' .Add "KEY_" & i - 2, tvwChild, "KEY_M" & i - 2,
Worksheets("team").Range("T2").Value & ": " &
Worksheets("team").Range("T" & i - 1).Value
' .Add "KEY_" & i - 2, tvwChild, "KEY_N" & i - 2,
Worksheets("team").Range("U2").Value & ": " &
Worksheets("team").Range("U" & i - 1).Value
' .Add "KEY_" & i - 2, tvwChild, "KEY_O" & i - 2,
Worksheets("team").Range("V2").Value & ": " &
Worksheets("team").Range("V" & i - 1).Value

' End If
Next i

End With

End Sub


thank for your help.

fulvio.

NB: i've other questions about this topic... but let's do it step by
step
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top