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 100 101 102 103 104 105
| Sub DataExportFr()
Dim Colonne As Byte
Dim trouve
With Sheets("Feuil1")
If UCase(Left(.Range("I2"), 2)) = "AV" Then
Colonne = Feuil2.Range("IV14").End(xlToLeft).Column + 1
If Colonne < 4 Then Colonne = 4
.Range("J2:J4").Copy Feuil2.Cells(14, Colonne)
.Range("E2").Copy Feuil2.Cells(8, Colonne)
.Range("F2").Copy Feuil2.Cells(9, Colonne)
.Range("G2").Copy Feuil2.Cells(10, Colonne)
.Range("H2").Copy Feuil2.Cells(12, Colonne)
.Range("B2").Copy Feuil2.Cells(13, Colonne)
.Range("J5").Copy Feuil2.Cells(17, Colonne)
With Feuil2.Cells(17, Colonne)
.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotBetween, _
Formula1:="16", Formula2:="22"
.FormatConditions(1).Font.ColorIndex = 3
.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="16", Formula2:="22"
.FormatConditions(2).Font.ColorIndex = 10
End With
ElseIf UCase(Left(.Range("I2"), 2)) = "RV" Then
Colonne = Feuil2.Range("IV43").End(xlToLeft).Column + 1
If Colonne < 12 Then Colonne = 12
.Range("J2:J4").Copy Feuil2.Cells(43, Colonne)
.Range("E2").Copy Feuil2.Cells(39, Colonne)
.Range("H2").Copy Feuil2.Cells(40, Colonne)
.Range("B2").Copy Feuil2.Cells(41, Colonne)
.Range("J5").Copy Feuil2.Cells(46, Colonne)
With Feuil2.Cells(46, Colonne)
.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotBetween, _
Formula1:="16", Formula2:="22"
.FormatConditions(1).Font.ColorIndex = 3
.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="16", Formula2:="22"
.FormatConditions(2).Font.ColorIndex = 10
End With
ElseIf UCase(Left(.Range("I2"), 2)) = "RP" Then
Colonne = Feuil2.Range("IV43").End(xlToLeft).Column + 1
If Colonne < 12 Then Colonne = 12
.Range("J2:J4").Copy Feuil2.Cells(43, Colonne)
Feuil2.Cells(43, Colonne).Font.ColorIndex = 5
Feuil2.Cells(44, Colonne).Font.ColorIndex = 5
Feuil2.Cells(45, Colonne).Font.ColorIndex = 5
.Range("E2").Copy Feuil2.Cells(39, Colonne)
.Range("H2").Copy Feuil2.Cells(40, Colonne)
.Range("B2").Copy Feuil2.Cells(41, Colonne)
Feuil2.Cells(39, Colonne).Font.ColorIndex = 5
Feuil2.Cells(40, Colonne).Font.ColorIndex = 5
Feuil2.Cells(41, Colonne).Font.ColorIndex = 5
.Range("J5").Copy Feuil2.Cells(46, Colonne)
With Feuil2.Cells(46, Colonne)
.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotBetween, _
Formula1:="16", Formula2:="23"
.FormatConditions(1).Font.ColorIndex = 3
.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="16", Formula2:="23"
.FormatConditions(2).Font.ColorIndex = 10
End With
ElseIf UCase(Left(.Range("I2"), 2)) = "AP" Then
Set trouve = Feuil2.Range("D8:IV8").Find(.Range("E2"), LookIn:=xlValues)
If trouve Is Nothing Then
MsgBox ("Cette valeur n'existe pas!")
Exit Sub
End If
.Range("J2:J4").Copy Feuil2.Cells(21, trouve.Column)
.Range("J5").Copy Feuil2.Cells(24, trouve.Column)
With Feuil2.Cells(24, trouve.Column)
.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotBetween, _
Formula1:="16", Formula2:="23"
.FormatConditions(1).Font.ColorIndex = 3
.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="16", Formula2:="23"
.FormatConditions(2).Font.ColorIndex = 10
End With
End If
Application.DisplayAlerts = False
Sheets("Feuil1").Select
Cells.ClearContents
Application.DisplayAlerts = True
Range("J5").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(R[-3]C:R[-1]C)"
Sheets("Feuil2").Select
End With
End Sub |
Partager