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
| Sub Consolidation()
Dim Sh As Worksheet, C As Range, Ligne As Integer
With Sheets("Menu")
.[A16:AP1000].ClearContents
For Each Sh In Worksheets
If Sh.Name <> "Menu" Then
col = Application.Match(Sh.Name, .[14:14], 0)
If Application.CountA(Sh.[D:D]) > 1 Then
For Each C In Sh.Range(Sh.[D2], Sh.Cells(Sh.Rows.Count, 4).End(xlUp))
If IsNumeric(Application.Match(C.Value, .[A1:A1000], 0)) Then
Ligne = Application.Match(C.Value, .[A1:A1000], 0)
Else
Ligne = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
End If
.Cells(Ligne, 1).Resize(, 3).Value = C.Resize(, 3).Value
.Cells(Ligne, col) = C.Offset(, 3)
.Cells(Ligne, col + 1) = C.Offset(, 4)
.Cells(Ligne, col + 2) = C.Offset(, 5)
.Cells(Ligne, 4).Formula = "=sumproduct(G" & Ligne & ":AP" & Ligne & "*(G15:AP15=""x""))"
.Cells(Ligne, 5).Formula = "=sumproduct(G" & Ligne & ":AP" & Ligne & "*(G15:AP15=""y""))"
.Cells(Ligne, 6).Formula = .Cells(Ligne, 4) / .Cells(Ligne, 5)
.Cells(Ligne, 6).NumberFormat = "#0.00%"
Next C
End If
End If
Next Sh
End With
End Sub |
Partager