Sub Synth()
ActiveWindow.Zoom = 70
Columns("A:A").ColumnWidth = 1.71
Columns("E:E").ColumnWidth = 0.5
Dim W As Integer
Dim H As Integer
Dim N As String
W = Worksheets.Count
Range("A1") = W
For i = 0 To W - 3
H = 3 + 11 * i
Worksheets(i + 3).Select
N = ActiveSheet.Name
Worksheets(1).Select
Range("B" & H) = N
Range("B" & H + 2) = "Coût Main d'Oeuvre"
Range("B" & H + 3) = "Coût Matières"
Range("B" & H + 4) = "TOTAL"
Range("B" & H + 5) = "Prix de revient 18.6"
Range("B" & H + 6) = "Prix de vente"
Range("B" & H + 7) = "Comission"
Range("B" & H + 8) = "Marge de vente"
Range("C" & H + 1) = "Alloué"
Range("D" & H + 1) = "Réel"
'Lien
Range("B" & H).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"'" & N & "'!A1"
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
End With
'Fusion smileys
Range("G" & H + 3 & ":G" & H + 4).Merge
'Formules
Range("C" & H + 2) = "='" & Range("B" & H) & "'![COLOR="Red"]$G$29[/COLOR]"
Range("C" & H + 3) = "='" & Range("B" & H) & "'![COLOR="red"]$G$33[/COLOR]"
Range("C" & H + 4) = "='" & Range("B" & H) & "'![COLOR="red"]$G$34[/COLOR]"
Range("D" & H + 2) = "='" & Range("B" & H) & "'![COLOR="red"]$H$29[/COLOR]"
Range("D" & H + 3) = "='" & Range("B" & H) & "'![COLOR="red"]$H$33[/COLOR]"
Range("D" & H + 4) = "='" & Range("B" & H) & "'![COLOR="red"]$H$34[/COLOR]"
Range("C" & H + 5).Formula = "=0.186*R[-1]C"
Range("C" & H + 5).AutoFill Destination:=Range("C" & H + 5 & ":D" & H + 5), Type:=xlFillDefault
Range("C" & H + 8).Formula = "=R[-2]C*(1-R[-1]C)-R[-3]C-R[-5]C-R[-6]C"
Range("C" & H + 8).AutoFill Destination:=Range("C" & H + 8 & ":D" & H + 8), Type:=xlFillDefault
Range("F" & H + 2).Formula = "=RC[-2]/RC[-3]-1"
Range("F" & H + 2).AutoFill Destination:=Range("F" & H + 2 & ":F" & H + 4), Type:=xlFillDefault
Range("G" & H + 3 & ":G" & H + 4).Formula = "=IF(R[1]C[-1]<-0.05,""J"",IF(R[1]C[-1]<0.05,""K"",""L""))"
'Format formules
Range("C" & H + 2 & ":D" & H + 8).NumberFormat = "0"
Range("C" & H + 7 & ":D" & H + 7).NumberFormat = "0.00%"
Range("G" & H + 3 & ":G" & H + 4).Select
With Selection.Font
.Name = "Wingdings"
.Size = 22
.Bold = True
End With
'Mise en forme conditionnelle
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""J"""
Selection.FormatConditions(1).Interior.ColorIndex = 42
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""K"""
Selection.FormatConditions(2).Interior.ColorIndex = 45
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""L"""
Selection.FormatConditions(3).Interior.ColorIndex = 3
'Cadre 1
Range("C" & H + 1 & ":D" & H + 1).Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'Cadre 2
Range("B" & H + 2 & ":D" & H + 4).Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("B" & H + 2 & ":B" & H + 4).Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
'Couleur
Range("C" & H + 6 & ":D" & H + 7).Select
Selection.Interior.ColorIndex = 36
Next
Range("A1").Select
End Sub