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
| Sub SumF()
Dim NbWs As Long, MonTot As Long, i As Long, c As Long, DerLig As Long
Dim MaPlage As Range, MaRech As Range
Dim ToSearch As String
NbWs = ActiveWorkbook.Worksheets.Count
For c = 1 To Cells(Columns(1).Cells.Count, 1).End(xlUp).Row
ToSearch = Worksheets(1).Cells(c, 1).Value
For i = 2 To NbWs
Worksheets(i).Select 'Obligatoire pour le Find
Set MaPlage = Worksheets(i).Range(Cells(1, 1), Cells(Cells(Columns(1).Cells.Count, 1).End(xlUp).Row, 1))
With MaPlage
Set MaRech = .Find(ToSearch, LookIn:=xlValues)
If Not MaRech Is Nothing Then
MonTot = MonTot + MaRech.Offset(0, 1).Value
End If
End With
Next i
Worksheets(1).Cells(c, 2) = MonTot
MonTot = 0
Next c
End Sub |
Partager