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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| Private Sub CmdTransfert_Click() ' BOUTON DE COMMANDE POUR LE TRANSFERT
Dim Tableau As Workbook
Dim Vacation As Workbook
Dim NomRubrique As Byte
Dim ligne, i As Byte
Dim ligneVac, VacLigne As Byte
Dim NomOnglet
Dim F_Tableau As Worksheet, F_BD As Worksheet
Set Tableau = ThisWorkbook
Set Vacation = ActiveWorkbook
Set F_Tableau = Tableau.Sheets("tableau")
Set F_BD = Tableau.Sheets("BD")
For NomRubrique = 2 To 9
i = 5
For ligne = 3 To 25
NomOnglet = F_BD.Cells(NomRubrique, 7).Value 'NomOnglet prend le nom de la rubrique
If F_Tableau.Cells(ligne, 1) <> "" And F_Tableau.Cells(ligne, 1) = NomOnglet Then
NomOnglet = F_BD.Cells(NomRubrique, 8).Value
With Vacation.Sheets(NomOnglet) '.Activate
For ligneVac = 5 To 25
ligneVac = i
If .Cells(5, 1).Value = "" Or .Cells(ligneVac, 1).Value = "" And .Cells(ligneVac - 1, 1) = F_Tableau.Cells(ligne, 2).Value Then
.Cells(ligneVac, 1).Value = F_Tableau.Cells(ligne, 2).Value 'matricule
.Cells(ligneVac, 2).Value = F_Tableau.Cells(ligne, 3).Value _
& " " & F_Tableau.Cells(ligne, 4).Value 'nom + prenom
.Cells(ligneVac, 4).Value = CDate(Left(F_Tableau.Cells(ligne, 5).Value, 10)) 'date debut
.Cells(ligneVac, 5).Value = Right(F_Tableau.Cells(ligne, 5).Value, 8) 'heure debut
.Cells(ligneVac, 6).Value = CDate(Left(F_Tableau.Cells(ligne, 6).Value, 10)) 'date fin
.Cells(ligneVac, 7).Value = Right(F_Tableau.Cells(ligne, 6).Value, 8) 'heure fin
.Cells(ligneVac, 9).Value = CDate(F_Tableau.Cells(ligne, 13).Value) 'heure
i = ligneVac
Exit For
ElseIf .Cells(ligneVac, 1) = "" And .Cells(ligneVac - 1, 1) <> F_Tableau.Cells(ligne, 2).Value _
And .Cells(ligneVac + 1, 1) = "" Then
ligneVac = ligneVac + 1
.Cells(ligneVac, 1).Value = F_Tableau.Cells(ligne, 2).Value 'matricule
.Cells(ligneVac, 2).Value = F_Tableau.Cells(ligne, 3).Value _
& " " & F_Tableau.Cells(ligne, 4).Value 'nom + prenom
.Cells(ligneVac, 4).Value = CDate(Left(F_Tableau.Cells(ligne, 5).Value, 10)) 'date debut
.Cells(ligneVac, 5).Value = Right(F_Tableau.Cells(ligne, 5).Value, 8) 'heure debut
.Cells(ligneVac, 6).Value = CDate(Left(F_Tableau.Cells(ligne, 6).Value, 10)) 'date fin
.Cells(ligneVac, 7).Value = Right(F_Tableau.Cells(ligne, 6).Value, 8) 'heure fin
.Cells(ligneVac, 9).Value = CDate(F_Tableau.Cells(ligne, 13).Value) 'heure
i = ligneVac
Exit For
Else
i = i + 1
End If
Next ligneVac
End With
End If
Next ligne
Next NomRubrique
Set Vacation = Nothing
Set Tableau = Nothing
End Sub |