VBA to populate userform listbox from a table (1 Viewer)

ritco

Registered User.
Local time
Today, 08:49
Joined
Apr 20, 2012
Messages
34
I am trying to find the correct VBA syntax to populate a listbox (on an Excel userform) with column headings, from a table reference.

The following code works but does not display column headings:
******************************************************************************************
Dim reqmstrRnge As Range

Set reqmstrRnge = ThisWorkbook.Worksheets("DataTbl").Range("tbl_ReqLogMstr")

.lstDatabase.ColumnCount = 16
.lstDatabase.ColumnHeads = True
.lstDatabase.List = reqmstrRnge.Cells.Value
*****************************************************************************************
1641917185363.png


I originally used .rowsource before I converted the data sheet into a table. I assume I'm not using correct syntax or table references don't work with .rowsource.
I have not been able to find anything on the web for this that works.
Any thoughts?
 

strive4peace

AWF VIP
Local time
Today, 10:49
Joined
Apr 3, 2020
Messages
1,003
hi @ritco,

does tbl_ReqLogMstr include the column headings in the fefinition? To find out, go to the Formulas ribbon tab, and then the Name Manager
 

Isaac

Lifelong Learner
Local time
Today, 08:49
Joined
Mar 14, 2017
Messages
8,738
Is the listbox's ColumnHeads property set to True?

Honestly, I usually forego the in-listbox headers, as I have found them to be inferior in various ways (but I can't remember what those are now, it's been about 10 months since I did that) - and draw labels on screen above the listbox object, instead.
 

Users who are viewing this thread

Top Bottom