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
| Private Sub Worksheet_Activate()
Dim NbFeuille, i As Integer
Dim PFeuille, Chant_a, Chant_b, Chant_c, Chant1, Chant2, Chant3 As Integer
Dim firstcell, lastcell, zone As Range
'PQR
NbFeuille = Worksheets.Count
PFeuille = 2
Chant_a = 0
Chant_b = 0
Chant_c = 0
For i = 3 To (NbFeuille - 1) Step 1
Sheets(i).Select
Set firstcell = Range("P5")
Set lastcell = Range("p65536").End(xlUp)
Set zone = Range(firstcell, lastcell)
Range(firstcell, lastcell).Select
ActiveCell.Offset(-1, 0).Select
Chant1 = ActiveCell.Value
Chant_a = Chant_a + Chant1
Set firstcell = Range("Q5")
Set lastcell = Range("Q65536").End(xlUp)
Set zone = Range(firstcell, lastcell)
Range(firstcell, lastcell).Select
ActiveCell.Offset(-1, 0).Select
Chant2 = ActiveCell.Value
Chant_b = Chant_b + Chant2
Set firstcell = Range("R5")
Set lastcell = Range("R65536").End(xlUp)
Set zone = Range(firstcell, lastcell)
Range(firstcell, lastcell).Select
ActiveCell.Offset(-1, 0).Select
Chant3 = ActiveCell.Value
Chant_c = Chant_c + Chant3
Debug.Print Chant_a
Next i
Worksheets(Worksheets.Count).Select
Range("b8").Value = Chant_a
Range("c8").Value = Chant_b
Range("d8").Value = Chant_c
End Sub |
Partager