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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
| Option Explicit
Dim Rep As Worksheet
Dim Mon As Worksheet
Dim PI As Worksheet
Dim i As Integer
Dim lr As Integer
Dim Tes As Worksheet
Dim Rep2 As Worksheet
Dim res As Variant
Dim f1 As Variant
Dim t As Variant
Dim Syn As Worksheet
Dim Mg As Worksheet
Dim j As Integer
Dim res1 As Variant
Dim res2 As Variant
Dim res3 As Variant
Sub Test()
Set Rep = Worksheets("Macro")
Set Mon = Worksheets("MoMO")
Set PI = Worksheets("PISTE")
Set Tes = Worksheets("Test")
Set Syn = Worksheets("Synthèse")
Set Mg = Worksheets("MagASIN")
lr = Range("A10000").End(xlUp).Row
Rep.Rows("6:1000").Clear
For j = 6 To 1000
Rep.Range("AB" & j).Value = Syn.Range("C" & j)
If Rep.Range("AB" & j).Value <> "" Then
Rep.Range("A" & j).Value = Rep.Range("B1").Value
Rep.Range("B" & j).Value = "Y"
res2 = Application.IfError(Application.VLookup(Rep.Range("AB" & j).Value, Mon.Range("Q:BR"), 54, 0), 0)
res3 = Application.IfError(Application.VLookup(Rep.Range("AB" & j).Value, Mg.Range("H:BF"), 51, 0), 0)
Rep.Range("C" & j).Value = Application.IfError((res2 / res3) * 100, 0)
Rep.Range("D" & j).Value = "EUR"
Rep.Range("T" & j).Value = "A"
Rep.Range("M" & j).Value = "D38"
Rep.Range("AF" & j).Value = Application.VLookup(Rep.Range("AB" & j).Value, Syn.Range("C:D"), 2, 0)
res1 = Application.VLookup(Rep.Range("AB" & j), PI.Range("E:G"), 3)
End If
If res1 = 0 Then
Rep.Range("F" & j).Value = 0
Else
Rep.Range("F" & j).Value = 1
End If
Next j
lr = Range("A10000").End(xlUp).Row
For i = 6 To 500
res = Application.IfError(Application.VLookup(Rep.Range("AB" & i), PI.Range("E:G"), 3, 0), "0%")
Rep.Range("AG" & i).Value = res
If Rep.Range("F" & i).Value = 1 And Rep.Range("AG" & i).Value > 0 And Rep.Range("AG" & i).Value < 1 Then
Tes.Range("AB" & i).Value = Rep.Range("AB" & i).Value
Tes.Range("C" & i).Value = Rep.Range("C" & i).Value * (1 - Rep.Range("AG" & i).Value)
Tes.Range("F" & i).Value = 0
Tes.Range("D" & i).Value = Rep.Range("D" & i).Value
Tes.Range("B" & i).Value = Rep.Range("B" & i).Value
Tes.Range("A" & i).Value = Rep.Range("A" & i).Value
Tes.Range("AG" & i).Value = Rep.Range("AG" & i).Value
Tes.Range("T" & i).Value = Rep.Range("T" & i).Value
Tes.Range("M" & i).Value = Rep.Range("M" & i).Value
Tes.Range("AF" & i).Value = Rep.Range("AF" & i).Value
Tes.Range("A" & i, "AZ" & i).Copy
Rep.Range("A" & i, "AZ" & i).Offset(1, 0).Rows.Insert
Rep.Range("C" & i).Value = Rep.Range("C" & i).Value * Range("AG" & i).Value
End If
Next i
End Sub |
Partager