I made this code below, and I am asking if anyone knows how to fix it, when I press on the command button an error shows up? I want to populate the list view with the table headers.
Here is a table for reference:
<tbody>
</tbody>
I am trying to get the code to populate the List View with table headers name.
Thank You
Code:
Private Sub CommandButton1_Click()
With ListView1Headers
.View = lvwReport
.CheckBoxes = True
.FullRowSelect = True
.Gridlines = True
With .ColumnHeaders
.Clear
.Add , , "Column Title Headers", 128
' .Add , , "Subitem-1", 70
' .Add , , "Subitem-2", 70
End With
End With
Me.ListView1Headers.Clear
mySheet = Me.ComboBox1.Value
'On Error Resume Next
lastCol = ThisWorkbook.Sheets(mySheet).Cells(TextBox1.Value, Columns.Count).End(xlToLeft).Column
For x = 1 To lastCol
Me.ListView1Headers.ListItems.Add ThisWorkbook.Sheets(mySheet).Cells(TextBox1.Value, x)
Next x
End Sub
Here is a table for reference:
A | B | C | D | E | |||||
1 | |||||||||
2 | Header1 |
<tbody> </tbody> |
<tbody> </tbody> |
<tbody> </tbody> |
<tbody> </tbody> | ||||
3 | |||||||||
4 |
<tbody>
</tbody>
I am trying to get the code to populate the List View with table headers name.
Thank You
Last edited: