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:
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Header1[/TD]
[TD]
<tbody>
</tbody>[/TD]
[TD]
<tbody>
</tbody>[/TD]
[TD]
<tbody>
</tbody>[/TD]
[TD]
<tbody>
</tbody>[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
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:
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Header1[/TD]
[TD]
Header2 |
<tbody>
</tbody>
[TD]
Header3 |
<tbody>
</tbody>
[TD]
Header4 |
<tbody>
</tbody>
[TD]
Header5 |
<tbody>
</tbody>
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I am trying to get the code to populate the List View with table headers name.
Thank You
Last edited: