Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default 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..
*****
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
added unwanted data in column daisydawg New Users to Excel 1 December 27th 08 09:55 PM
avoiding duplicates in listbox (added from another listbox) KR Excel Programming 4 March 14th 06 08:17 PM
Associate External Data with an added column cujimm Excel Discussion (Misc queries) 1 December 9th 05 03:59 PM
Populate 2-column ListBox with 2 non-contiguous columns Paul Martin Excel Programming 2 December 8th 04 01:45 AM
Multi-column ListBox. Multiple bound columns??? Joe Mathis Excel Programming 5 December 10th 03 01:32 AM


All times are GMT +1. The time now is 12:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"