PC Review


Reply
Thread Tools Rate Thread

Data is added in 1 column instaed of 4 columns (in listbox)

 
 
=?Utf-8?B?QXJqYW4=?=
Guest
Posts: n/a
 
      19th Oct 2006
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..
*****
 
Reply With Quote
 
 
 
 
Mike Woodhouse
Guest
Posts: n/a
 
      19th Oct 2006


On Oct 19, 1:13 pm, Arjan <A...@discussions.microsoft.com> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to print all columns from a multi column listbox? Jim Cone Microsoft Excel Programming 1 31st Mar 2010 10:31 PM
Can't added two columns from one listbox to two columns in another Webtechie Microsoft Excel Programming 4 21st Aug 2009 03:48 AM
Help with scolling a listbox while data is being added Jason Microsoft C# .NET 7 17th Jul 2009 07:26 PM
multi-column listbox columns mcourter@mindspring.com Microsoft Access Form Coding 1 24th Oct 2005 06:39 PM
Populate 2-column ListBox with 2 non-contiguous columns Paul Martin Microsoft Excel Programming 2 8th Dec 2004 01:45 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:52 PM.