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 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
| Sub MIN()
'Calcule les prix minimum pour chaque référence
Dim PrixMinSept As Variant
Dim PrixMinHuit As Variant
Dim PrixMinNeuf As Variant
Dim PrixMinDix As Variant
Dim x As Integer
Dim l As Integer
Dim c As Integer
' Modifier le numéro du premier onglet Société
For x = 5 To Sheets.Count
' Modifier l'intervalle des lignes de produits pour tous les onglets société
For l = 4 To 160
PrixMinSept = 10000
PrixMinHuit = 10000
PrixMinNeuf = 10000
PrixMinDix = 10000
' Modifier le nombre limite de facture à prendre en compte
For c = 1 To 60
If Sheets(x).Cells(3, 3 * c + 7).Value = "PU" Then
If Format(Sheets(x).Cells(2, 3 * c + 8).Value, "dd/mm/yyyy") < 1 / 1 / 2008 Then
If (PrixMinSept > Sheets(x).Cells(l, 3 * c + 7).Value) And (Sheets(x).Cells(l, 3 * c + 7).Value <> 0) Then
PrixMinSept = Sheets(x).Cells(l, 3 * c + 7).Value
End If
ElseIf (Format(Sheets(x).Cells(2, 3 * c + 8).Value, "dd/mm/yyyy") < 1 / 1 / 2009) And (Format(Sheets(x).Cells(2, 3 * c + 8).Value, "dd/mm/yyyy") > 31 / 12 / 2007) Then
If (PrixMinHuit > Sheets(x).Cells(l, 3 * c + 7).Value) And (Sheets(x).Cells(l, 3 * c + 7).Value <> 0) Then
PrixMinHuit = Sheets(x).Cells(l, 3 * c + 7).Value
End If
ElseIf (Format(Sheets(x).Cells(2, 3 * c + 8).Value, "dd/mm/yyyy") < 1 / 1 / 2010) And (Format(Sheets(x).Cells(2, 3 * c + 8).Value, "dd/mm/yyyy") > 31 / 12 / 2008) Then
If (PrixMinNeuf > Sheets(x).Cells(l, 3 * c + 7).Value) And (Sheets(x).Cells(l, 3 * c + 7).Value <> 0) Then
PrixMinNeuf = Sheets(x).Cells(l, 3 * c + 7).Value
End If
ElseIf Format(Sheets(x).Cells(2, 3 * c + 8).Value, "dd/mm/yyyy") > 31 / 12 / 2009 Then
If (PrixMinDix > Sheets(x).Cells(l, 3 * c + 7).Value) And (Sheets(x).Cells(l, 3 * c + 7).Value <> 0) Then
PrixMinDix = Sheets(x).Cells(l, 3 * c + 7).Value
End If
End If
End If
Next c
'Rentre les prix Min dans les colonnes d'année correspondante
Sheets(x).Cells(l, 5).Value = PrixMinSept
Sheets(x).Cells(l, 6).Value = PrixMinHuit
Sheets(x).Cells(l, 7).Value = PrixMinNeuf
Sheets(x).Cells(l, 8).Value = PrixMinDix
' Remplace les cases ayant la valeur 10000 par ""
For c = 5 To 8
If Sheets(x).Cells(l, c).Value = 10000 Then
Sheets(x).Cells(l, c).Value = ""
End If
Next c
Next l
Next x
End Sub |
Partager