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
|
Const Summary As String = "Stock"
Const NumLigne As Integer = 2
Const NumColonne As Integer = 1
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim c As Range
Dim wSh As Object
If Sh.Name = Summary _
Then
For Each Sh In ThisWorkbook.Sheets
If Sh.Name <> Summary Then
Set wSh = Worksheets(Summary)
With wSh
For Each c In .Range(.Cells(NumLigne, NumColonne), _
.Cells(.Cells(Rows.Count, NumColonne).End(xlUp).Row, NumColonne))
If c.Text = Sh.Name Then _
c.Offset(, 1).Value = Worksheets(Sh.Name).Range("B2").Value
'ici tu mets les cellules que tu veux mettre à jour
'
'
Next c
End With
End If
Next Sh
Else
End If
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Dim c As Range
Dim wSh As Object
With Sh
If .Name = Summary _
Then
For Each c In .Range(.Cells(NumLigne, NumColonne), _
.Cells(.Cells(Rows.Count, NumColonne).End(xlUp).Row, NumColonne))
For Each wSh In ThisWorkbook.Sheets
If wSh.Name <> Summary And c.Value = wSh.Name Then
For i = NumLigne To wSh.Cells(Rows.Count, NumColonne).End(xlUp).Row
If wSh.Cells(i, NumColonne) = c.Value Then
wSh.Cells(i, NumColonne + 1) = c.Offset(, 1).Value
'ici tu mets les cellules que tu veux mettre à jour
'
'
End If
Next i
End If
Next wSh
Next c
End If
End With
End Sub |