| 12
 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
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 
 | Ce n'est pas les photos les plus récentes mais c'est le même principe et voila le code en question:
For i = 2 To 20
    If Cells(8, i) = "Oui" Then
 
        lig = ligne() ' voir dans module1
        'on selectionne ici l'onglet qui est contenue dans B4 au coordonnées voulu
        'Cas où on étudie le premier levier
        If i = 2 Then
         'Cas où l'on étudie l'on fait varier le Coût moyen par site
            If Cells(6, i).Value = "Coût moyen par site initial" Then
                If Cells(4, i) = "Situation Initiale" Then
                    Worksheets("Situation initiale optimisée").Cells(7, 2).Value = Worksheets("Solutions").Cells(3, i).Value
                    Else
                    Worksheets("Situation actuelle optimisée").Cells(7, 2).Value = Worksheets("Solutions").Cells(3, i).Value
                End If
        ElseIf Cells(4, i) = "Situation Initiale" Then
        'On selectionne le bon onglet où affecter les modifications
            Worksheets("Situation initiale optimisée").Cells(lig, Cells(5, i).Value + 2).Value = Worksheets(Cells(4, i).Value).Cells(lig, Cells(5, i).Value + 2).Value + Worksheets("Solutions").Cells(7, i).Value - Worksheets("Solutions").Cells(3, i).Value
            Else
            Worksheets("Situation actuelle optimisée").Cells(lig, Cells(5, i).Value + 2).Value = Worksheets(Cells(4, i).Value).Cells(lig, Cells(5, i).Value + 2).Value + Worksheets("Solutions").Cells(7, i).Value - Worksheets("Solutions").Cells(3, i).Value
        End If
 
        'Cas où l'on étudie les autres leviers
        Else: For j = 2 To (i - 1)
       'Cas où l'on étudie l'on fait varier le Coût moyen par site
            If Cells(6, i).Value = "Coût moyen par site initial" Then
                If Cells(4, i) = "Situation Initiale" Then
                    Worksheets("Situation initiale optimisée").Cells(7, 2).Value = Worksheets("Solutions").Cells(3, i).Value
                    Else
                    Worksheets("Situation actuelle optimisée").Cells(7, 2).Value = Worksheets("Solutions").Cells(3, i).Value
                End If
            ElseIf Cells(5, j).Value = Cells(5, i).Value Then
                If Cells(6, j).Value = Cells(6, i).Value Then
                    If Cells(4, i) = "Situation Initiale" Then
        'Cas où il existe déjà une modification sur cette cellule
            Worksheets("Situation initiale optimisée").Cells(lig, Cells(5, i).Value + 2).Value = Worksheets("Situation initiale optimisée").Cells(lig, Cells(5, i).Value + 2).Value + Worksheets("Solutions").Cells(7, i).Value - Worksheets("Solutions").Cells(3, i).Value
                    Else
            Worksheets("Situation actuelle optimisée").Cells(lig, Cells(5, i).Value + 2).Value = Worksheets("Situation actuelle optimisée").Cells(lig, Cells(5, i).Value + 2).Value + Worksheets("Solutions").Cells(7, i).Value - Worksheets("Solutions").Cells(3, i).Value
                    End If
                    ElseIf Cells(4, i) = "Situation Initiale" Then
 
        'Cas où l'on ne retrouve que la même période impacté
            Worksheets("Situation initiale optimisée").Cells(lig, Cells(5, i).Value + 2).Value = Worksheets(Cells(4, i).Value).Cells(lig, Cells(5, i).Value + 2).Value + Worksheets("Solutions").Cells(7, i).Value - Worksheets("Solutions").Cells(3, i).Value
                Else
            Worksheets("Situation actuelle optimisée").Cells(lig, Cells(5, i).Value + 2).Value = Worksheets(Cells(4, i).Value).Cells(lig, Cells(5, i).Value + 2).Value + Worksheets("Solutions").Cells(7, i).Value - Worksheets("Solutions").Cells(3, i).Value
                End If
            ElseIf Cells(4, i) = "Situation Initiale" Then
 
        'Cas où aucune des informations ne sont les mêmes
            Worksheets("Situation initiale optimisée").Cells(lig, Cells(5, i).Value + 2).Value = Worksheets(Cells(4, i).Value).Cells(lig, Cells(5, i).Value + 2).Value + Worksheets("Solutions").Cells(7, i).Value - Worksheets("Solutions").Cells(3, i).Value
            Else
            Worksheets("Situation actuelle optimisée").Cells(lig, Cells(5, i).Value + 2).Value = Worksheets(Cells(4, i).Value).Cells(lig, Cells(5, i).Value + 2).Value + Worksheets("Solutions").Cells(7, i).Value - Worksheets("Solutions").Cells(3, i).Value
            End If
    Next j
            End If
    ElseIf Cells(8, i) = "Non" Then
            MsgBox ("La solution " & i - 1 & " n'est pas retenue")
    Else
    End If
Next i
End Sub | 
Partager