voila la macro
Option Explicit
Sub moyennetit()
Dim i As Integer, j As Integer, a As Single, b As Single
Application.ScreenUpdating = False
Range("S1:X200").ClearContents
Range("T6").Select
ActiveCell.Offset(-1, 0) = "Colonne"
ActiveCell.Offset(-1, 1) = "Ligne"
ActiveCell.Offset(-1, 2) = "Valeur"
ActiveCell.Offset(-1, 3) = "Moyenne"
For i = 1 To 25
ActiveCell = 4
ActiveCell.Offset(1, 0) = 8
ActiveCell.Offset(2, 0) = 12
ActiveCell.Offset(3, 0) = 16
ActiveCell.Offset(0, 1) = i + 5
ActiveCell.Offset(1, 1) = i + 5
ActiveCell.Offset(2, 1) = i + 5
ActiveCell.Offset(3, 1) = i + 5
ActiveCell.Offset(0, 2).FormulaR1C1 = "=INDEX(R1C1:R30C17,RC[-1],RC[-2])"
ActiveCell.Offset(1, 2).FormulaR1C1 = "=INDEX(R1C1:R30C17,RC[-1],RC[-2])"
ActiveCell.Offset(2, 2).FormulaR1C1 = "=INDEX(R1C1:R30C17,RC[-1],RC[-2])"
ActiveCell.Offset(3, 2).FormulaR1C1 = "=INDEX(R1C1:R30C17,RC[-1],RC[-2])"
ActiveCell.Offset(4, 0).Select
Next
Range("V6:V105").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
For i = 7 To 105 ' toutes les lignes de la colonne V, premier passage
Cells(i, 22).Select
If ActiveCell = "" Then
ActiveCell = 0
End If
Next
Range("X7").FormulaR1C1 = "=SUM(RC[-2]:R105C22)"
Range("X7").AutoFill Destination:=Range("X7:X105"), Type:=xlFillDefault
For i = 7 To 105 ' toutes les lignes de la colonne V, deuxième passage
Cells(i, 22).Select
If ActiveCell.Offset(0, 2) = 0 Then
GoTo Etiquette
End If
If ActiveCell = 0 Then
Do While ActiveCell <= 0
ActiveCell.Offset(-1, 0).Select
Loop
a = ActiveCell.Value
Cells(i, 22).Select
Do While ActiveCell <= 0 Or ActiveCell = ""
ActiveCell.Offset(1, 0).Select
Loop
b = ActiveCell.Value
Cells(i, 22).Offset(0, 1) = (a + b) / 2
Cells(Cells(i, 22).Offset(0, -1), Cells(i, 22).Offset(0, -2)) = Cells(i, 22).Offset(0, 1)
End If
Next
Etiquette:
Range("A1").Select
Range("S1:X200").ClearContents
End Sub
Sub Macro4()
Range("D7,H9,P6,P8:P11,L15:L16,P20:P21,D16").ClearContents
Range("A1").Select
End Sub
et je voudrais pour D6
d6 =SI(ET(A6>=$C$2;A6<=$F$2);INDEX('B-Formulation'!P:P;EQUIV(A6;'B-Formulation'!A:A;0));"")
et appliquer cette formule à D 7
d6 =SI(ET(A7>=$C$2;A7<=$F$2);INDEX('B-Formulation'!P:P;EQUIV(A7;'B-Formulation'!A:A;0));"")
ceci jusqu a D29
avec cette base je ferais de meme pour E6 H6 I6 L6 M6 P6et Q6