29 | 03 | 2017

Multiple Columns in Listbox

In a VBA Listbox it is possible to add multiple columns. Code below shows a sample of how to add three columns to a listbox.  

Sub AddMultipleColumn()
'Add multiple Columns to a listbox
ListBox1.Clear 'Make sure the Listbox is empty
ListBox1.ColumnCount = 3 'Set the column Amount
'Fill the Listbox
ListBox1.AddItem "Row Number 1" 'Additem creates a new row
ListBox1.List(0, 1) = "Column Number 2" 'List(x,y) X is the row number, Y the column number
ListBox1.List(0, 2) = "Column Number 3"
ListBox1.List(0, 3) = "Column Number 4"
ListBox1.AddItem "Row Number 2"
ListBox1.List(1, 1) = "Column Number 2"
ListBox1.List(1, 2) = "Column Number 3"
ListBox1.List(1, 3) = "Column Number 4"
ListBox1.AddItem "Row Number 3"
ListBox1.List(2, 1) = "Column Number 2"
ListBox1.List(2, 2) = "Column Number 3"
ListBox1.List(2, 3) = "Column Number 4"
End Sub
 
 
Result is shown below:
Download the source code below (Registered users only). 
Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2211967
Latest Articles