Sub recaps()
'See http://www.mrexcel.com/forum/questions-other-languages/841535-need-little-help-visual-basic-applications-besoin-daide-sur-un-code-visual-basic-applications-sans-pivot-table-ni-sumprod-2.html
Dim wArr, mySumm As Worksheet, I As Long, hArr, myMatch, myStart As String
Dim res1Arr() As Single, res2Arr() As Single, myTim As Single, myDataSh As String
Dim LBwArrV As Long, UBwArrV As Long, LBwArrH As Long, UBwArrH As Long
Dim PersCnt As Long, Pers2Cnt As Long, J As Long
'
myDataSh = "Feuil1" '<<< 1 See Message
myStart = "N1" '<<< 2 See Message
Set mySumm = Sheets("RECAP") '<<< 3 !! SEE MESSAGE !!
'
myTim = Timer
Sheets(myDataSh).Activate
wArr = Range(Range(myStart).End(xlDown), Range(myStart).End(xlToRight)).Value 'Data to array
mySumm.Cells.ClearContents 'Clear Summary sheet
hArr = Application.WorksheetFunction.Index(wArr, 1, 0) 'Get Data header
LBwArrV = LBound(wArr, 1): UBwArrV = UBound(wArr, 1)
LBwArrH = LBound(wArr, 2): UBwArrH = UBound(wArr, 2)
'
mySumm.Range("A1").Resize(1, UBound(wArr, 2)).Value = hArr 'Fill headers in Summary
ReDim res1Arr(LBound(wArr, 1) To UBound(wArr, 1), LBound(wArr, 2) To UBound(wArr, 2)) 'redim results1 array
ReDim res2Arr(LBound(wArr, 1) To UBound(wArr, 1), LBound(wArr, 2) To UBound(wArr, 2)) 'redim results2 array
'
'Calculate first Summary (Personne / Date):
For I = LBwArrV + 1 To UBwArrV
'First Summary: Current name already in Summary?
myMatch = Application.Match(wArr(I, 1), mySumm.Range("A1").Resize(UBwArrV, 1), False)
If IsError(myMatch) Then
mySumm.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = wArr(I, 1) 'Missing, add it
myMatch = PersCnt + 2: PersCnt = PersCnt + 1
End If
For J = LBwArrH + 2 To UBwArrH 'Sum activities for each day
res1Arr(myMatch - 1, J - 2) = res1Arr(myMatch - 1, J - 2) + wArr(I, J)
Next J
Next I
'
'Reloop for second Summary (Personne & Activité / Date):
mySumm.Range("A1").Offset(PersCnt + 5, 0).Resize(1, UBound(wArr, 2)).Value = hArr 'Fill headers in Summary
For I = LBwArrV + 1 To UBwArrV
'Second Summary: Current name/Activity already in Summary?
myMatch = Application.Match(wArr(I, 1) & Chr(124) & wArr(I, 2), _
mySumm.Range("A1").Offset(PersCnt + 5, 0).Resize(UBwArrV, 1), False)
If IsError(myMatch) Then
mySumm.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = _
wArr(I, 1) & Chr(124) & wArr(I, 2) 'Missing, add it
myMatch = Pers2Cnt + 2: Pers2Cnt = Pers2Cnt + 1
End If
For J = LBwArrH + 2 To UBwArrH 'Sum activities for each day
res2Arr(myMatch - 1, J - 2) = res2Arr(myMatch - 1, J - 2) + wArr(I, J)
Next J
Next I
'Write results on Output Sheet
mySumm.Range("C2").Resize(PersCnt, UBwArrH - 2).Value = res1Arr 'Write first Summary
mySumm.Range("C2").Offset(PersCnt + 5, 0).Resize(Pers2Cnt, UBwArrH - 2).Value = res2Arr 'Write second Summary
'Split Personne | Activité:
mySumm.Range("A2").Offset(PersCnt + 5, 0).Resize(Pers2Cnt, 1).TextToColumns _
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, Other:=True, OtherChar _
:="|", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
'
mySumm.Cells.EntireColumn.AutoFit
'
MsgBox ("Traitement terminé, durée " & Format(Timer - myTim, "0.00") & " Secondes")
End Sub