Private Sub CommandButton1_Click()
remplissage ListView1, [A1:C26] 'sans entete
'remplissage ListView1, [A1:C26], True 'avec entete
End Sub
Function remplissage(lstVW, plage, Optional header As Boolean = False)
Dim i&, c&, x&
With lstVW
.SetFocus
.ListItems.Clear
With .ColumnHeaders
.Clear
For i = 1 To plage.Columns.Count: .Add , , plage.Cells(i), plage.Cells(i).Width: Next
End With
.View = lvwReport ' type Report
.FullRowSelect = True ' sélection complète de la ligne
.HideColumnHeaders = Not header ' Masque les en-têtes de colonnes
'.CheckBoxes = False
'.Gridlines = True
End With
If header Then x = 1
For i = 1 + x To plage.Rows.Count
lstVW.ListItems.Add i - x, , plage.Cells(i, 1) '<--- modifier l'instruction pour ajouter
For c = 2 To plage.Columns.Count
lstVW.ListItems(lstVW.ListItems.Count).ListSubItems.Add c - 1, , plage.Cells(i, c)
Next
Next
End Function