Sub transfert()
MessageErreur = ""
Dim PlageS As Range
Dim PlageQ As Range
Dim PlageD As Range
Dim PlageC As Range
With Sheets("Feuil1") 'on définit les plages S Q D et C
Jour = .Range("C26")
Set PlageS = .Range("B30:J37")
Set PlageQ = .Range("B39:J46")
Set PlageD = .Range("B48:J55")
Set PlageC = .Range("B57:J64")
End With
'on check si les plages sont remplies avec toutes les infos
chkS = CheckPlage(PlageS, "S")
chkQ = CheckPlage(PlageQ, "Q")
chkd = CheckPlage(PlageD, "D")
chkC = CheckPlage(PlageC, "C")
'si il manque une info quelque part, un message apparait
If Not chkS Or Not chkQ Or Not chkd Or Not chkC Then
If MsgBox(MessageErreur & Chr(10) & Chr(10) & Chr(10) & "Souhaitez vous continuer?", vbYesNo) = vbNo Then Exit Sub
End If
'remplissage de la table BD_TODO
With Sheets("Feuil4").ListObjects("BD_TODO")
'PlageS
If chkS Then
.ListRows.Add 'on ajoute une ligne
LastLine = .ListRows.Count 'dernière ligne
'on colle les infos
.DataBodyRange(LastLine, 1) = Jour 'Jour
.DataBodyRange(LastLine, 2) = PlageS.Cells(1, 2) 'Statut
.DataBodyRange(LastLine, 3) = "S" 'Acronyme
.DataBodyRange(LastLine, 4) = PlageS.Cells(8, 7) 'Société
.DataBodyRange(LastLine, 5) = PlageS.Cells(3, 2) 'Description pb
.DataBodyRange(LastLine, 6) = PlageS.Cells(3, 6) 'Action
.DataBodyRange(LastLine, 7) = PlageS.Cells(8, 3) 'Pilote
.DataBodyRange(LastLine, 8) = PlageS.Cells(8, 9) 'Date objectif
.DataBodyRange(LastLine, 9) = "?" 'Date Cloture
.DataBodyRange(LastLine, 10) = "?" 'Escalader
.DataBodyRange(LastLine, 11) = "?" 'Info
End If
'idem pour la plage suivante
If checkQ Then
'PlageQ
.ListRows.Add
LastLine = .ListRows.Count
.DataBodyRange(LastLine, 1) = Jour 'Jour
.DataBodyRange(LastLine, 2) = PlageQ.Cells(1, 2) 'Statut
.DataBodyRange(LastLine, 3) = "Q" 'Acronyme
.DataBodyRange(LastLine, 4) = PlageQ.Cells(8, 7) 'Société
.DataBodyRange(LastLine, 5) = PlageQ.Cells(3, 2) 'Description pb
.DataBodyRange(LastLine, 6) = PlageQ.Cells(3, 6) 'Action
.DataBodyRange(LastLine, 7) = PlageQ.Cells(8, 3) 'Pilote
.DataBodyRange(LastLine, 8) = PlageQ.Cells(8, 9) 'Date objectif
.DataBodyRange(LastLine, 9) = "?" 'Date Cloture
.DataBodyRange(LastLine, 10) = "?" 'Escalader
.DataBodyRange(LastLine, 11) = "?" 'Info
End If
If chekcD Then
'PlageD
.ListRows.Add
LastLine = .ListRows.Count
.DataBodyRange(LastLine, 1) = Jour 'Jour
.DataBodyRange(LastLine, 2) = PlageD.Cells(1, 2) 'Statut
.DataBodyRange(LastLine, 3) = "D" 'Acronyme
.DataBodyRange(LastLine, 4) = PlageD.Cells(8, 7) 'Société
.DataBodyRange(LastLine, 5) = PlageD.Cells(3, 2) 'Description pb
.DataBodyRange(LastLine, 6) = PlageD.Cells(3, 6) 'Action
.DataBodyRange(LastLine, 7) = PlageD.Cells(8, 3) 'Pilote
.DataBodyRange(LastLine, 8) = PlageD.Cells(8, 9) 'Date objectif
.DataBodyRange(LastLine, 9) = "?" 'Date Cloture
.DataBodyRange(LastLine, 10) = "?" 'Escalader
.DataBodyRange(LastLine, 11) = "?" 'Info
End If
If checkC Then
'PlageC
.ListRows.Add
LastLine = .ListRows.Count
.DataBodyRange(LastLine, 1) = Jour 'Jour
.DataBodyRange(LastLine, 2) = PlageC.Cells(1, 2) 'Statut
.DataBodyRange(LastLine, 3) = "C" 'Acronyme
.DataBodyRange(LastLine, 4) = PlageC.Cells(8, 7) 'Société
.DataBodyRange(LastLine, 5) = PlageC.Cells(3, 2) 'Description pb
.DataBodyRange(LastLine, 6) = PlageC.Cells(3, 6) 'Action
.DataBodyRange(LastLine, 7) = PlageC.Cells(8, 3) 'Pilote
.DataBodyRange(LastLine, 8) = PlageC.Cells(8, 9) 'Date objectif
.DataBodyRange(LastLine, 9) = "?" 'Date Cloture
.DataBodyRange(LastLine, 10) = "?" 'Escalader
.DataBodyRange(LastLine, 11) = "?" 'Info
End If
End With
End Sub