Quantcast
Channel: Active questions tagged listview - Stack Overflow
Viewing all articles
Browse latest Browse all 611

Excel VBA ListView Headers Bold

$
0
0

I am new to VBA and struggling to make my ListView (named "lvRec") headers bold only.

The ListView is in a userform, Excel populated from the currect workbook, "MySales" table.How to format headers, please?

Private Sub UserForm_Activate()    Dim ws As Worksheet    Dim tbl As ListObject    Dim lv As ListItem    Dim i As Integer, n As Integer    Set ws = ThisWorkbook.Worksheets("Sheet1")    Set tbl = ws.ListObjects("MySales")    With Me.lvRec        .Gridlines = True        .HoverSelection = True        .View = lvwReport    End With'Add column headers    For i = 1 To tbl.ListColumns.Count        Me.lvRec.ColumnHeaders.Add , , tbl.ListColumns(i).Name    Next i    With tbl.Range        For i = 2 To .Rows.Count            Set lv = Me.lvRec.ListItems.Add(, , tbl.Range.Cells(i, 1).Text)            For n = 2 To .Columns.Count                lv.ListSubItems.Add , , tbl.Range.Cells(i, n).Text            Next n        Next i    End WithEnd Sub

I have searched online, but couldn't apply what I have found. They mentioned "Font" property, but i couldn't call it for headers.


Viewing all articles
Browse latest Browse all 611

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>