Quelques suggestions en vrac et mal dégrossies que tu trouveras dans ce code (je tourne un peu en rond au boulot cet aprèm... )
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B1")) Is Nothing Then
Dim cel As Range, col1 As Byte, col2 As Byte, ligfin As Byte
col1 = 3
ligfin = Range("A2").End(xlDown).Row
With Range("C3:AC23")
.ClearContents
.Interior.ColorIndex = xlNone
.NumberFormat = "0%"
End With
For Each cel In Range("C2:AC2")
If cel = "" And Not cel.Offset(0, -1) = "" Then
col2 = cel.Column
With cel.Offset(1, 0)
.FormulaR1C1 = "=AVERAGE(RC[-" & col2 - col1 & "]:RC[-1])"
.Interior.ColorIndex = 8
.NumberFormat = "0.00"
.AutoFill Destination:=Range(Cells(3, col2), Cells(ligfin, col2)), Type:=xlFillDefault
End With
With Range("C25")
.FormulaArray = _
"=AVERAGE(IF(R3C2:R" & ligfin & "C2=""TDP"",R3C:R" & ligfin & "C))"
.AutoFill Destination:=Range("C25:AC25"), Type:=xlFillDefault
End With
col1 = col2 + 1
End If
Next cel
For Each cel In Range("B3:B" & ligfin)
If cel = "Taches" Then Range(Cells(cel.Row, 3), Cells(cel.Row, 29)).NumberFormat = "0"
Next cel
End If
End Sub
Explications en gros :
- la macro se lance quand on change la valeur de B2
- elle efface le contenu et la couleur de ta plage de données C2:AC23
- attribue un format de cellule pourcentage à toutes les "TDP" et "PERF", un format nombre à toutes les "Taches"
- écrit les formules = MOYENNE(semaine passée) dans les colonnes w-e
Pour le calcul des moyennes globales quotidiennes et hebdomadaires, je suggère une formule matricielle puisque j'ai enfin réussi à comprendre un bout du principe :
en C25 :
=MOYENNE(SI($B$3:$B$11="TDP";C$3:C$11))
en C26 :
=MOYENNE(SI($B$3:$B$11="PERF";C$3:C$11))
en C27 :
=MOYENNE(SI($B$3:$B$11="Taches";C$3:C$11))
Formules à valider par Ctrl + Maj + Entrée, puis à étirer vers la droite
PS : je ne pourrai certainement pas donner trop de suite, étant donné que je n'ai plus internet à la maison... Donc si quelqu'un peut embrayer dessus pas de soucis