VBA to populate userform listbox from a table

ritco

Registered User.
Local time
Yesterday, 16:58
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?
 
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
 
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

Back
Top Bottom