Excel vba listbox column header

JJGeyLoungerPosts: 49Joined: 21 Dec 2015, 01:19

How to add a header to multi-column list box in VBA userform

  • Quote
Is it possible to add a header to each column to this list box in a userform

Here is a sample code for the list box
This code is running outside any of the office applications like Word or Excel

Code: Select all

Private Sub UserForm_Initialize() '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.AddItem "Row Number 2" ListBox1.AddItem "Row Number 3" ListBox1.List(0, 1) = "Column 2 Row 1" 'List(x,y) X is the row number, Y the column number ListBox1.List(0, 2) = "Column 3 Row 1" ListBox1.List(2, 1) = "Column 2 Row 3" ListBox1.List(2, 2) = "Column 3 Row 3" ListBox1.List(1, 1) = "Column 2 Row 2" ListBox1.List(1, 2) = "Column 3 Row 2" End Sub
Here is the result of the above code
2017-04-20_7-07-00.png (4.8 KiB) Viewed 10388 times
Top