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
| Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim kR As Long, nMat As Variant, wShSuivi As Worksheet
Dim wbFV As Workbook, wShFV As Worksheet, ok As Boolean
If Target.Count > 1 Then Exit Sub
If Target.Value = "" Then Exit Sub
If Target.Column < 13 Or Target.Column > 15 Then Exit Sub
If Target.Row < 7 Then Exit Sub
kR = Target.Row
If Cells(kR, 13).Value = "" Or Cells(kR, 14).Value = "" Or Cells(kR, 15).Value = "" Then Exit Sub
nMat = Cells(kR, 2).Value '--- n° matricule
Set wShSuivi = ActiveSheet
Application.ScreenUpdating = False
Workbooks.Open ThisWorkbook.Path & "\Fiche validation.xlsm"
ok = False
For Each wShFV In Worksheets
If wShFV.Range("E7").Value = nMat Then
ok = True
wShFV.Range("M8") = wShSuivi.Cells(kR, 13).Value '--- responsable
wShFV.Range("M9") = wShSuivi.Cells(kR, 14).Value '--- date
wShFV.Range("N9") = wShSuivi.Cells(kR, 15).Value '--- résultat
wShFV.Activate
wShFV.Range("N9").Select
Exit For
End If
Next wShFV
ActiveWorkbook.Close True '--- ferme en sauvant
Set wShSuivi = Nothing
Application.ScreenUpdating = True
If ok = False Then MsgBox "Matricule " & nMat & " non trouvé!", , "Pour info"
End Sub |
Partager