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
| Private Sub Worksheet_Change(ByVal Target As Range)
Application.DisplayAlerts = 0: Application.EnableEvents = 0
i = Target.Row
If Cells(i, 1) = "" Then Application.EnableEvents = -1: Exit Sub
'Récupération de l'Identifiant de la ligne modifiée
Id = Cells(i, 1)
'On cherche l'Id dans la colonne A de Base
'Si on le trouve
If Not IsError(Application.Match(Id, Sheets("Base").Columns(1), 0)) Then
'Mise en majuscule et nom propre des Nom et Prénom
Cells(i, 4) = StrConv(Cells(i, 4), 1)
With Sheets("Base")
'Si l'Id est trouvé
If Not IsError(Application.Match(Id, .Columns(1), 0)) Then
j = Application.Match(Id, .Columns(1), 0)
'on copie les données modifiée dans Base
.Cells(j, 2).Resize(, 4).Value = Cells(i, 2).Resize(, 4).Value
.Cells(j, 25) = Cells(i, 6)
.Cells(j, 28) = Cells(i, 7)
.Cells(j, 29) = Cells(i, 8)
.Cells(j, 808) = Cells(i, 9)
.Cells(j, 809) = Cells(i, 10)
.Cells(j, 810).Risize(, 4).Value = Cells(i, 11).Resize(, 4).Value
.Cells(j, 814).Resize(, 17).Value = Cells(i, 15).Resize(, 17).Value
Cells(i, 10) = "=IF(COUNTA(O5:AE5),"""",""X"")"
End If
End With
End If
Application.DisplayAlerts = -1: Application.EnableEvents = -1
End Sub
Private Sub Worksheet_Activate()
Application.DisplayAlerts = 0: Application.EnableEvents = 0
'A l'activation de la feuille
'On cherche la dernière ligne pleine pour supprimer les données
j = [A65536].End(xlUp).Row
If j > 4 Then Rows("5:" & j).ClearContents
With ("Base")
'Pour toutes les lignes de "Base"
For j = 3 To .[A65536].End(xlUp).Row
If .Cells(j, 2) <> "" Then
'On copie les données de Base dans la feuille activée
i = [A65536].End(xlUp)(2).Row
Cells(i, 1).Resize(, 5).Value = .Cells(j, 1).Resize(, 5).Value
Cells(i, 6) = .Cells(j, 25)
Cells(i, 7) = .Cells(j, 28)
Cells(i, 8) = .Cells(j, 29)
Cells(i, 9) = .Cells(j, 808)
Cells(i, 10) = .Cells(j, 809)
Cells(i, 11).Resize(, 4).Value = .Cells(j, 810).Resize(, 4).Value
Cells(i, 15).Resize(, 17).Value = .Cells(j, 814).Resize(, 17).Value
Cells(i, 10) = "=IF(COUNTA(O5:AE5),"""",""X"")"
End If
Next
End With
j = [A65536].End(xlUp).Row
If j > 4 Then Range("A5:AE" & [D65536].End(xlUp).Row).Sort [D5], xlAscending, [E5], , xlAscending, , , xlNo
Application.DisplayAlerts = -1: Application.EnableEvents = -1
End Sub |