PDA

View Full Version : listbox columnheading



Kim75
05-06-2010, 02:19 PM
Hi the forum,

I looked for a long time for the means to fill column headers of a userform listbox, but in vain, may be someone know how we can do that …

Here is my code (word 2002) :Private Sub UserForm_Initialize()
Dim myArray1 As Variant
Dim myArray2 As Variant
Dim myArray3 As Variant
Dim myArray4 As Variant
Dim myArray5 As Variant
Dim myArray6 As Variant
Dim myArray7 As Variant
Dim i As Long
myArray1 = Split("aaaaa|bbbbb|ccccc|ddddd|eeeee|" _
& "xixixi|fffff|ggggg|hhhhh|iiiii|" _
& "jjjjj|kkkkk|lllll|mmmmm|nnnnn|" _
& "ooooo|ppppp|qqqqq|rrrrr|sssss|" _
& "ttttt|uuuuu|vvvvv|wwwww|xxxxx|" _
& "rsrsrs|ststst|tututu|uvuvuv|vwvwvw|", "|")
myArray2 = Split("aaaaa|bbbbb|ccccc|ddddd|eeeee|" _
& "xixixi|fffff|ggggg|hhhhh|iiiii|" _
& "jjjjj|kkkkk|lllll|mmmmm|nnnnn|" _
& "ooooo|ppppp|qqqqq|rrrrr|sssss|" _
& "ttttt|uuuuu|vvvvv|wwwww|xxxxx|" _
& "rsrsrs|ststst|tututu|uvuvuv|vwvwvw|", "|")
myArray3 = Split("aaaaa|bbbbb|ccccc|ddddd|eeeee|" _
& "xixixi|fffff|ggggg|hhhhh|iiiii|" _
& "jjjjj|kkkkk|lllll|mmmmm|nnnnn|" _
& "ooooo|ppppp|qqqqq|rrrrr|sssss|" _
& "ttttt|uuuuu|vvvvv|wwwww|xxxxx|" _
& "rsrsrs|ststst|tututu|uvuvuv|vwvwvw|", "|")
myArray4 = Split("aaaaa|bbbbb|ccccc|ddddd|eeeee|" _
& "xixixi|fffff|ggggg|hhhhh|iiiii|" _
& "jjjjj|kkkkk|lllll|mmmmm|nnnnn|" _
& "ooooo|ppppp|qqqqq|rrrrr|sssss|" _
& "ttttt|uuuuu|vvvvv|wwwww|xxxxx|" _
& "rsrsrs|ststst|tututu|uvuvuv|vwvwvw|", "|")
myArray5 = Split("aaaaa|bbbbb|ccccc|ddddd|eeeee|" _
& "xixixi|fffff|ggggg|hhhhh|iiiii|" _
& "jjjjj|kkkkk|lllll|mmmmm|nnnnn|" _
& "ooooo|ppppp|qqqqq|rrrrr|sssss|" _
& "ttttt|uuuuu|vvvvv|wwwww|xxxxx|" _
& "rsrsrs|ststst|tututu|uvuvuv|vwvwvw|", "|")
myArray6 = Split("aaaaa|bbbbb|ccccc|ddddd|eeeee|" _
& "xixixi|fffff|ggggg|hhhhh|iiiii|" _
& "jjjjj|kkkkk|lllll|mmmmm|nnnnn|" _
& "ooooo|ppppp|qqqqq|rrrrr|sssss|" _
& "ttttt|uuuuu|vvvvv|wwwww|xxxxx|" _
& "rsrsrs|ststst|tututu|uvuvuv|vwvwvw|", "|")
myArray7 = Split("aaaaa|bbbbb|ccccc|ddddd|eeeee|" _
& "xixixi|fffff|ggggg|hhhhh|iiiii|" _
& "jjjjj|kkkkk|lllll|mmmmm|nnnnn|" _
& "ooooo|ppppp|qqqqq|rrrrr|sssss|" _
& "ttttt|uuuuu|vvvvv|wwwww|xxxxx|" _
& "rsrsrs|ststst|tututu|uvuvuv|vwvwvw|", "|")
For i = 0 To UBound(myArray1)
ListBox1.AddItem
ListBox1.List(i, 0) = myArray1(i)
ListBox1.List(i, 1) = myArray2(i)
ListBox1.List(i, 2) = myArray3(i)
ListBox1.List(i, 3) = myArray4(i)
ListBox1.List(i, 4) = myArray5(i)
ListBox1.List(i, 5) = myArray6(i)
ListBox1.List(i, 6) = myArray7(i)
Next i
End Sub
thanks, Kim

Paul_Hossler
05-06-2010, 03:36 PM
You can't set the Listbox headers via VBA. In Excel you can reference cells on a worksheet, but that's about it

Paul

fumei
05-07-2010, 12:25 PM
What is worse is that if you read Help, it seems like you can. However, Paul is correct, this is a very annoying not possible.

Kim75
05-07-2010, 12:49 PM
What is worse is that if you read Help, it seems like you can. However, Paul is correct, this is a very annoying not possible.

Hi Gerry :hi:

I read the help and hundreds of subjects on Google, and I did not find, then I said to myself that because one day this creature whom is the man was able to put his feet on the moon :stars: , it is not impossible that one day he can put headers in listbox :dunno

friendly, Kim