Listbox Header not display results

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,075
Office Version
  1. 2019
Platform
  1. Windows
I have a header in cell DB6 and DC6 (Symbol & Profit/Loss). I'm trying to get the header to show in the listbox header, but it is being displayed under the listbox header. May i receive assistance resolving this issue.

thanks

VBA Code:
Private Sub lbDec_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Dim LRow As Long
    Dim Wks As Worksheet
    
    Set Wks = ActiveSheet
    LRow = Wks.Cells(Wks.Rows.Count, "DB").End(xlUp).Row
    
    With ListBox1
        .List = Wks.Range("DB6:DC" & LRow).Value
        .ColumnCount = 2
        .ColumnHeads = True
        .ColumnWidths = "40;40"
    End With
    lbMonth.Visible = True
    obHrs.Value = True
End Sub

1702959340296.png
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
You'll need to use the RowSource property of the ListBox, instead of the List property. And you'll need to exclude the header row...

VBA Code:
.RowSource = Wks.Range("DB7:DC" & LRow).Address(external:=True)

Hope this helps!
 
Upvote 0
When you try loading a list Box not using its RowSource it starts loading from the row before the header, even if you set ColumnHeads = True. See if this helps?


VBA Code:
Private Sub lbDec_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Dim Wb As Workbook, Wks As Worksheet, Rng1 As Range
    
    Set Wb = ThisWorkbook
    Set Wks = Wb.Worksheets("Sheet1")
    Set Rng1 = Wks.Range("A2:A" & Wks.Cells(Wks.Rows.Count, "A").End(xlUp).Row)
    With Me.ListBox1
       .ColumnHeads = True
       .ColumnCount = Rng1.Columns.Count
       .ColumnWidths = "40,40"
       .RowSource = Rng1.Parent.Name & "!" & Rng1.Resize(Rng1.Rows.Count - 1).Offset(1).Address
     End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,201
Members
453,022
Latest member
RobertV1609

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