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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
| Sub Lance()
Application.Run "Nouvelles_Factures"
End Sub
Sub Nouvelles_Factures()
Dim x As Long
Dim Y As Long
Sheets("Modèle").Select
Range("I2").Select
x = Range("I2").Value
ActiveCell.FormulaR1C1 = x + 1
Sheets("Modèle").Copy After:=Sheets(2)
Sheets("Modèle (2)").Select
Range("C13").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
With ActiveWorkbook.Sheets("Modèle (2)").Tab
.ThemeColor = xlThemeColorAccent2
.TintAndShade = 0.399975585192419
End With
Sheets("Synthèse").Select
Range("B65536").Select
Selection.End(xlUp).Select
Y = ActiveCell.Row
Range("B" & Y + 1).Select
ActiveCell.FormulaR1C1 = "='Modèle (2)'!I5"
Range("C" & Y + 1).Select
ActiveCell.FormulaR1C1 = "='Modèle (2)'!I2"
Range("D" & Y + 1).Select
ActiveCell.FormulaR1C1 = "='Modèle (2)'!C13"
Range("E" & Y + 1).Select
ActiveCell.FormulaR1C1 = "='Modèle (2)'!F25"
Range("F" & Y + 1).Select
ActiveCell.FormulaR1C1 = "='Modèle (2)'!I33"
Range("G" & Y + 1).Select
ActiveCell.FormulaR1C1 = "='Modèle (2)'!H25"
Range("H" & Y + 1).Select
ActiveCell.FormulaR1C1 = "='Modèle (2)'!I35"
Range("C5").Select
ActiveCell.FormulaR1C1 = "=COUNT(R[3]C:R[" & Y - 4 & "]C)"
Range("E5").Select
ActiveCell.FormulaR1C1 = "=SUM(R[3]C:R[" & Y - 4 & "]C)"
Range("F5").Select
ActiveCell.FormulaR1C1 = "=SUM(R[3]C:R[" & Y - 4 & "]C)"
Range("G5").Select
ActiveCell.FormulaR1C1 = "=SUM(R[3]C:R[" & Y - 4 & "]C)"
Range("H5").Select
ActiveCell.FormulaR1C1 = "=SUM(R[3]C:R[" & Y - 4 & "]C)"
Range("H6").Select
Range("B" & Y + 1 & ":H" & Y + 1).Select
Selection.Replace What:="'I5'", Replacement:="I5", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="'I2'", Replacement:="I2", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="$M:$M", Replacement:="C13", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="'C13'", Replacement:="C13", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="'F25'", Replacement:="F25", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="'I33'", Replacement:="I33", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="'H25'", Replacement:="H25", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="'I35'", Replacement:="I35", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("B" & Y + 1 & ":J" & Y + 1).Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
Range("I" & Y + 1).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$L$1:$L$2"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("J" & Y + 1).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$M$1:$M$3"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("D" & Y + 1).Select
Selection.NumberFormat = "m/d/yyyy"
Range("E" & Y + 1 & ":H" & Y + 1).Select
Selection.NumberFormat = "#,##0.00 $"
Range("A1").Select
Sheets("Modèle (2)").Select
Sheets("Modèle (2)").Name = "Facture N°" & x + 1
Range("A1").Select
End Sub |
Partager