populate colum headers on userform

timecop79

New Member
Joined
Apr 8, 2023
Messages
16
Office Version
  1. 2016
Platform
  1. Windows
  2. Mobile
How do I populate the colum headers of a list box with some headings.
I can populate the 'body' of the list box with text of various columns and rows wide, but how do I populate the headers. The property 'ColumnHeader ' just gives me a Boolean value, and just makes the heafers visible.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi
The ListBox control will only display column headers when using the RowSource property to populate it & the ColumnHeads property is set to True

You can read a general guide here: VBA Listbox - A Complete Guide - Excel Macro Mastery.

Dave
I tried a lot of thing but nothing work, I think I'm making a mistake but don't know what exactly, my headers can't be displayed, je peut partager mon code et une image de l'anomalie
 
Upvote 0
Post code you are having issues with - plenty here to offer guidance

Dave
 
Upvote 0
here the code:

VBA Code:
Sub refresh_data()

Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Historique inter")
Dim last_row As Long
last_row = Application.WorksheetFunction.CountA(sh.Range("A:A"))

With Me.ListBox1
     .ColumnHeads = True
     .ColumnCount = 12
     .ColumnWidths = "70;70;70;70;70;70;70;70;70;70;70;70"
     .List = sh.Range("A2", "L" & sh.Range("A" & Rows.Count).End(xlUp).Row).Value
 End With
    
End Sub


here the image , you can see headers one row donw
 

Attachments

  • ENTETE.jpg
    ENTETE.jpg
    166.5 KB · Views: 6
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,054
Latest member
juliecooper255

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top