1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| Private Sub CommandButton1_Click()
Dim Ws As Worksheet
Dim ListObj As ListObject
Dim NomTableau As String
Dim DerLign As Long
Set Ws = Worksheets("feuil1")
For Each ListObj In Ws.ListObjects
NomTableau = ListObj.Name
Next
If NomTableau <> "" Then
If NomTableau <> "Tableau1" Then
Worksheets("feuil1").ListObjects(NomTableau).Name = "Tableau1"
End If
Else
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$C$13:$P$14"), , xlYes).Name = "Tableau1"
End If
If ListBox1.ListCount <> 0 Then
With Sheets("feuil1").ListObjects("Tableau1")
i = .ListRows.Count
.ListRows.Add
i = .ListColumns("Colonne1").Range.Find("", SearchDirection:=xlNext).Row
i = i - .HeaderRowRange.Row
a = ListBox1.ListCount - 1
For NumList = 0 To a
.ListColumns("Colonne1").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 2)
.ListColumns("Colonne2").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 3)
.ListColumns("Colonne3").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 4)
.ListColumns("Colonne4").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 5)
.ListColumns("Colonne5").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 6)
.ListColumns("Colonne6").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 7)
.ListColumns("Colonne7").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 8)
.ListColumns("Colonne8").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 9)
.ListColumns("Colonne9").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 10)
.ListColumns("Colonne10").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 11)
.ListColumns("Colonne11").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 12)
.ListColumns("Colonne12").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 13)
.ListColumns("Colonne13").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 14)
.ListColumns("Colonne14").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 15)
.ListColumns("Colonne15").DataBodyRange.Rows(i).Value = ListBox1.List(NumList, 16)
i = i + 1
Next NumList
End With
Else
MsgBox "la Liste est vide"
End If
End Sub |
Partager