![]() |
Data is added in 1 column instaed of 4 columns (in listbox)
Hi all,
I am adding a range of data (4 coloms wide) from a worksheet to a listbox with a commandbutton. However, the data is 4 coloms wide. The data added is put below each other instead of besised each other.. What can I do to make the data in the 4 coloumns? Please find below my code I use at this moment.. --------------------------------------------- Private Sub Commandbutton1_Click() ' bepalen hoe breed de kolommen moeten zijn Me.ListBox1.ColumnWidths = "360;28;53;50" 'hier wordt de listbox range bepaald zodat de juiste range in het juiste tabblad komt. Dim dpv2 As Long Dim dpv22 As Long ListBox1.Clear ListBox1.ColumnCount = 4 ListBox1.RowSource = "" For dpv2 = 1 To 63 ListBox1.AddItem Sheets("DPV 2").Range("a" & dpv2).Value ListBox1.AddItem Sheets("DPV 2").Range("b" & dpv2).Value ListBox1.AddItem Sheets("DPV 2").Range("c" & dpv2).Value ListBox1.AddItem Sheets("DPV 2").Range("d" & dpv2).Value Next dpv2 End Sub ------------------------------------------ Arjan Bregman ***** the knowledge is always there, maybe hidden, but it is there.. ***** |
Data is added in 1 column instaed of 4 columns (in listbox)
On Oct 19, 1:13 pm, Arjan wrote: Hi all, I am adding a range of data (4 coloms wide) from a worksheet to a listbox with a commandbutton. However, the data is 4 coloms wide. The data added is put below each other instead of besised each other.. What can I do to make the data in the 4 coloumns? Try this, which I just lifted from http://www.chalouhis.com/XLBLOG/arch...olumn-listbox/ Const NumColumns = 3 Const NumRows = 10 Dim i As Integer, j As Integer For i = 1 To NumRows lstMyListBox.AddItem €śRow€ť & i & €śColumn1€ł For j = 1 To NumColumns - 1 lstMyListBox.List(i - 1, j) = €śRow€ť & i & €śColumn€ť & j Next j Next i HTH, Mike |
All times are GMT +1. The time now is 12:42 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com