ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Won't Add Multicolumn Data (https://www.excelbanter.com/excel-programming/363573-wont-add-multicolumn-data.html)

Brandon Johnson

Won't Add Multicolumn Data
 
I jsut need to be able to add these values to the listbox. I have 13
columns and is set to 75 pt column width.

lstResults.AddItem A(1) & ";" & A(2) & ";" & A(3) & ";" & A(4) & ";" &
A(5) & ";" & A(6) & ";" & A(7) & ";" & A(8) & ";" & A(9) & ";" & A(10)
& ";" & A(11) & ";" & A(12) & ";" & A(13)


Brandon Johnson

Won't Add Multicolumn Data
 
It lists all the data in the first cell

Brandon Johnson wrote:
I jsut need to be able to add these values to the listbox. I have 13
columns and is set to 75 pt column width.

lstResults.AddItem A(1) & ";" & A(2) & ";" & A(3) & ";" & A(4) & ";" &
A(5) & ";" & A(6) & ";" & A(7) & ";" & A(8) & ";" & A(9) & ";" & A(10)
& ";" & A(11) & ";" & A(12) & ";" & A(13)



Tom Ogilvy

Won't Add Multicolumn Data
 
With lstResults
.AddItem A(1)
for j = 2 to 13
.List(.Listcount-1,j - 1) = A(j)
Next
end With

--
Regards,
Tom Ogilvy


"Brandon Johnson" wrote:

It lists all the data in the first cell

Brandon Johnson wrote:
I jsut need to be able to add these values to the listbox. I have 13
columns and is set to 75 pt column width.

lstResults.AddItem A(1) & ";" & A(2) & ";" & A(3) & ";" & A(4) & ";" &
A(5) & ";" & A(6) & ";" & A(7) & ";" & A(8) & ";" & A(9) & ";" & A(10)
& ";" & A(11) & ";" & A(12) & ";" & A(13)




Brandon Johnson

Won't Add Multicolumn Data
 
thanks for the reply. however it throws me a runtime 381 error when it
trys to fire off the .list property. any thoughts?

Tom Ogilvy wrote:
With lstResults
.AddItem A(1)
for j = 2 to 13
.List(.Listcount-1,j - 1) = A(j)
Next
end With

--
Regards,
Tom Ogilvy


"Brandon Johnson" wrote:

It lists all the data in the first cell

Brandon Johnson wrote:
I jsut need to be able to add these values to the listbox. I have 13
columns and is set to 75 pt column width.

lstResults.AddItem A(1) & ";" & A(2) & ";" & A(3) & ";" & A(4) & ";" &
A(5) & ";" & A(6) & ";" & A(7) & ";" & A(8) & ";" & A(9) & ";" & A(10)
& ";" & A(11) & ";" & A(12) & ";" & A(13)





Tom Ogilvy

Won't Add Multicolumn Data
 
My oversight, the method I suggested only works for up to 10 columns:

Private Sub UserForm_Initialize()
Dim a(1 To 10) As Long
With lstResult
.ColumnCount = 10
.ColumnWidths = "75;75;75;75;75;75;75;75;75;75;75;75;75"
For i = 1 To 25 ' 25 rows
For j = 1 To 10 ' 10 columns
' populate the array with dummy values
' for testing
a(j) = Int(Rnd() * 100 + 1)
Next
.AddItem a(i)
For j = 2 To 10
.List(.ListCount - 1, j - 1) = a(j)
Next
Next
End With
End Sub

For 13 columns, you will need to populate your data like this:

Private Sub UserForm_Initialize()
Dim a(1 To 25, 1 To 13) As Long
With lstResult
.ColumnCount = 13
.ColumnWidths = "75;75;75;75;75;75;75;75;75;75;75;75;75"
For i = 1 To 25 ' 25 rows
For j = 1 To 13 ' 13 columns
a(i, j) = Int(Rnd() * 100 + 1)
Next
Next
' assign the 25 x 13 array to list all at once
.List = a
End With
End Sub


--
Regards,
Tom Ogilvy

"Brandon Johnson" wrote:

thanks for the reply. however it throws me a runtime 381 error when it
trys to fire off the .list property. any thoughts?

Tom Ogilvy wrote:
With lstResults
.AddItem A(1)
for j = 2 to 13
.List(.Listcount-1,j - 1) = A(j)
Next
end With

--
Regards,
Tom Ogilvy


"Brandon Johnson" wrote:

It lists all the data in the first cell

Brandon Johnson wrote:
I jsut need to be able to add these values to the listbox. I have 13
columns and is set to 75 pt column width.

lstResults.AddItem A(1) & ";" & A(2) & ";" & A(3) & ";" & A(4) & ";" &
A(5) & ";" & A(6) & ";" & A(7) & ";" & A(8) & ";" & A(9) & ";" & A(10)
& ";" & A(11) & ";" & A(12) & ";" & A(13)





Dave Peterson

Won't Add Multicolumn Data
 
I've never had to use a listbox with that many columns.

But I always believed help:

Setting ColumnCount to 0 displays zero columns, and setting it to -1 displays
all the available columns. For an unbound data source, there is a 10-column
limit (0 to 9).

Thanks for shaking my beliefs once more <vbg.



Tom Ogilvy wrote:

My oversight, the method I suggested only works for up to 10 columns:

Private Sub UserForm_Initialize()
Dim a(1 To 10) As Long
With lstResult
.ColumnCount = 10
.ColumnWidths = "75;75;75;75;75;75;75;75;75;75;75;75;75"
For i = 1 To 25 ' 25 rows
For j = 1 To 10 ' 10 columns
' populate the array with dummy values
' for testing
a(j) = Int(Rnd() * 100 + 1)
Next
.AddItem a(i)
For j = 2 To 10
.List(.ListCount - 1, j - 1) = a(j)
Next
Next
End With
End Sub

For 13 columns, you will need to populate your data like this:

Private Sub UserForm_Initialize()
Dim a(1 To 25, 1 To 13) As Long
With lstResult
.ColumnCount = 13
.ColumnWidths = "75;75;75;75;75;75;75;75;75;75;75;75;75"
For i = 1 To 25 ' 25 rows
For j = 1 To 13 ' 13 columns
a(i, j) = Int(Rnd() * 100 + 1)
Next
Next
' assign the 25 x 13 array to list all at once
.List = a
End With
End Sub

--
Regards,
Tom Ogilvy

"Brandon Johnson" wrote:

thanks for the reply. however it throws me a runtime 381 error when it
trys to fire off the .list property. any thoughts?

Tom Ogilvy wrote:
With lstResults
.AddItem A(1)
for j = 2 to 13
.List(.Listcount-1,j - 1) = A(j)
Next
end With

--
Regards,
Tom Ogilvy


"Brandon Johnson" wrote:

It lists all the data in the first cell

Brandon Johnson wrote:
I jsut need to be able to add these values to the listbox. I have 13
columns and is set to 75 pt column width.

lstResults.AddItem A(1) & ";" & A(2) & ";" & A(3) & ";" & A(4) & ";" &
A(5) & ";" & A(6) & ";" & A(7) & ";" & A(8) & ";" & A(9) & ";" & A(10)
& ";" & A(11) & ";" & A(12) & ";" & A(13)





--

Dave Peterson


All times are GMT +1. The time now is 12:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com