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
| Sub CreateLine(rowExport)
Dim FL1 As Worksheet, FL2 As Worksheet
Dim DerniereLigne As Integer
Set FL1 = Worksheets("SUIVI TDMI BYT")
Set FL2 = Worksheets("Export Infocentre")
DerniereLigne = FL1.Range("A" & Rows.Count).End(xlUp).Row + 1
FL2.Rows(rowExport).Copy FL1.Cells(Rows.Count, 1).End(xlUp)(2)
FL1.Cells(DerniereLigne, 32) = Format(Now, "dd/mm/yyyy")
FL1.Range("A" & DerniereLigne).Interior.Color = RGB(0, 255, 0)
End Sub
Sub UpdateLine(rowSuivi, rowExport)
Dim FL1 As Worksheet, FL2 As Worksheet
Set FL1 = Worksheets("SUIVI TDMI BYT")
Set FL2 = Worksheets("Export Infocentre")
FL1.Range("A" & rowSuivi).Interior.Color = RGB(255, 0, 0)
FL1.Cells(rowSuivi, 23) = FL2.Cells(rowExport, 23)
FL1.Cells(rowSuivi, 24) = FL2.Cells(rowExport, 24)
FL1.Cells(rowSuivi, 25) = FL2.Cells(rowExport, 25)
FL1.Cells(rowSuivi, 26) = FL2.Cells(rowExport, 26)
FL1.Cells(rowSuivi, 27) = FL2.Cells(rowExport, 27)
FL1.Cells(rowSuivi, 28) = FL2.Cells(rowExport, 28)
FL1.Cells(rowSuivi, 29) = FL2.Cells(rowExport, 29)
FL1.Cells(rowSuivi, 30) = FL2.Cells(rowExport, 30)
FL1.Cells(rowSuivi, 32) = Format(Now, "dd/mm/yyyy")
End Sub
Sub For_X_to_Next_Ligne()
Dim FL1 As Worksheet, NoCol As Integer
Dim NoLig As Long, Var As Variant
Set FL1 = Worksheets("Export Infocentre")
NoCol = 1 'lecture de la colonne 1
For NoLig = 2 To Split(FL1.UsedRange.Address, "$")(4)
Var = FL1.Cells(NoLig, NoCol)
Set Find = Sheets("SUIVI TDMI BYT").Columns("A").Find(Var)
If Find Is Nothing Then
Call CreateLine(NoLig)
Else
Range(Find, Find).Select
rowSuivi = ActiveCell.Row
Call UpdateLine(rowSuivi, NoLig)
End If
Next
Set FL1 = Nothing
End Sub |
Partager