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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
| Option Explicit
Dim nbrpt As Single
Dim j, i, h, Nave, Nopt, Nproto, NRevprix, ligne As Integer
Dim T As String
Dim somPF, somBPU, monPF, monBPU, monTPA, somTPA, somTOT As Currency
Private Sub Image2_Click() 'clic sur le bouton annuler
'réinitialize toutes les box
Range("zz1").Value = ""
TextBox2.Value = ""
TextBox6.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""
TextBox8.Value = ""
TextBox9.Value = ""
ComboBox1.Value = ""
description_du_contrat.Hide 'cache l'useform
End Sub
Private Sub Image3_Click() 'clic sur bouton valider
If Len(Me.ComboBox1) = 0 Then
MsgBox "Le champ Type d'élément du contrat est champ vide ! veuillez sélectionner un type d'élément du contrat"
Exit Sub
End If
If Len(Me.TextBox3) = 0 Then
MsgBox "Veuillez renseigner le n° de commande PGI"
Exit Sub
End If
If Len(Me.TextBox4) < 4 Then
MsgBox "Saisir l'année de la base économique sur 4 chiffres"
Exit Sub
End If
If Len(Me.TextBox7) = 0 Then
MsgBox "Veuillez renseigner la date de signature des CPA"
Exit Sub
End If
If Sheets("description du contrat").Range("zz1").Value = "" Then
ajout
Else:
modif
End If
End Sub
Sub modif()
Sheets("description du contrat").Activate
ligne = Sheets("description du contrat").Range("zz1").Value
Range("zz1").Value = ""
somPF = 0
somBPU = 0
somTPA = 0
nbrpt = 0
For j = 0 To 10000
If Range("B29").Offset(j) = "Total" Then 'quand une cellule est vide le prg s'arrête
Exit For
Else
nbrpt = nbrpt + 1 'si une ase est rempli nbrpt s'incrémente
End If
Next j
T = ComboBox1.Value
monPF = TextBox5.Value
monBPU = TextBox6.Value
monTPA = TextBox9.Value
Range("b" & ligne).Value = T
Range("b" & ligne).EntireColumn.AutoFit
Range("c" & ligne).Value = TextBox2.Value
Range("C" & ligne).EntireColumn.AutoFit
Range("D" & ligne).Value = TextBox3.Value
Range("D" & ligne).EntireColumn.AutoFit
Range("E" & ligne).Value = Format("euro " & TextBox4)
Range("E" & ligne).EntireColumn.AutoFit
Range("f" & ligne).Value = monPF
Range("f" & ligne).NumberFormat = "_-* #,##0.00 [$-40C]_-;-* #,##0.00 [$-40C]_-;_-* ""-""?? [$-40C]_-;_-@_-"
Range("F" & ligne).EntireColumn.AutoFit
Range("g" & ligne).Value = monBPU
Range("g" & ligne).NumberFormat = "_-* #,##0.00 [$-40C]_-;-* #,##0.00 [$-40C]_-;_-* ""-""?? [$-40C]_-;_-@_-"
Range("G" & ligne).EntireColumn.AutoFit
Range("h" & ligne).NumberFormat = "_-* #,##0.00 [$-40C]_-;-* #,##0.00 [$-40C]_-;_-* ""-""?? [$-40C]_-;_-@_-"
Range("h" & ligne).Value = monTPA
Range("j" & ligne).NumberFormat = "_-* #,##0.00 [$-40C]_-;-* #,##0.00 [$-40C]_-;_-* ""-""?? [$-40C]_-;_-@_-"
Range("j" & ligne).Value = Range("f" & ligne).Value + Range("g" & ligne).Value + Range("h" & ligne).Value
Range("J" & ligne).EntireColumn.AutoFit
Range("k" & ligne).Value = TextBox7.Value
Range("K" & ligne).EntireColumn.AutoFit
Range("l" & ligne).Value = TextBox8.Value
Range("l" & ligne).EntireColumn.AutoFit
For h = 0 To nbrpt - 1
somPF = somPF + Range("f29").Offset(h).Value
somBPU = somBPU + Range("g29").Offset(h).Value
somTPA = somTPA + Range("h29").Offset(h).Value
Next h
Range("f29").Offset(nbrpt) = somPF
Range("g29").Offset(nbrpt) = somBPU
Range("h29").Offset(nbrpt) = somTPA
somTOT = somPF + somBPU + somTPA
Range("j29").Offset(nbrpt).NumberFormat = "_-* #,##0.00 [$-40C]_-;-* #,##0.00 [$-40C]_-;_-* ""-""?? [$-40C]_-;_-@_-"
Range("j29").Offset(nbrpt) = somTOT
If ComboBox1.Value = "Marché" Then
Range("d9").Value = TextBox2.Value
Range("d10").Value = TextBox3.Value
Range("d18").Value = TextBox2.Value
Range("d24").Value = TextBox7.Value
Range("M12").Value = TextBox7.Value
Range("M13").Value = TextBox7.Value
End If
If ComboBox1.Value Like "Avenant *" Then
Range("f10").Value = TextBox3.Value
Range("f24").Value = TextBox7.Value
End If
TextBox2.Value = ""
TextBox6.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""
TextBox8.Value = ""
TextBox9.Value = ""
ComboBox1.Value = ""
description_du_contrat.Hide
Sheets("description du contrat").Activate
End Sub
Sub ajout()
Sheets("description du contrat").Activate
somPF = 0
somBPU = 0
somTPA = 0
nbrpt = 0
For j = 0 To 10000
If Range("B29").Offset(j) = "" Then 'quand une cellule est vide le prg s'arrête
Exit For
Else
nbrpt = nbrpt + 1 'si une ase est rempli nbrpt s'incrémente
End If
Next j
T = ComboBox1.Value
For j = 0 To nbrpt
If Range("B29").Offset(j).Value = T Then
Rows("29:29").Offset(j).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Exit For
End If
If Range("B29").Offset(j).Value = "Total" Then
Rows("29:29").Offset(j).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Exit For
End If
Next j
With Rows("29:29").Offset(j)
.RowHeight = 23.25
.Font.Size = 11
.Interior.ColorIndex = 2
.Font.ColorIndex = 1
End With
If T = "Avenant" Then
Nave = Nave + 1
T = "Avenant " & Nave
End If
If T = "Option" Then
Nopt = Nopt + 1
T = "Option " & Nopt
End If
If T = "Protocole" Then
Nproto = Nproto + 1
T = "Protocole " & Nproto
End If
If T = "Révision de prix" Then
NRevprix = NRevprix + 1
T = "Révision de prix " & Nproto
End If
monPF = TextBox5.Value
monBPU = TextBox6.Value
monTPA = TextBox9.Value
Range("b29").Offset(j).Value = T
Range("b29").Offset(j).EntireColumn.AutoFit
Range("c29").Offset(j).Value = TextBox2.Value
Range("c29").Offset(j).EntireColumn.AutoFit
Range("D29").Offset(j).Value = TextBox3.Value
Range("d29").Offset(j).EntireColumn.AutoFit
Range("E29").Offset(j).Value = Format("euro " & TextBox4)
Range("E29").Offset(j).NumberFormat = "#,##0.00 $"
Range("e29").Offset(j).EntireColumn.AutoFit
Range("f29").Offset(j).Value = monPF
Range("f29").Offset(j).NumberFormat = "_-* #,##0.00 [$-40C]_-;-* #,##0.00 [$-40C]_-;_-* ""-""?? [$-40C]_-;_-@_-"
Range("f29").Offset(j).EntireColumn.AutoFit
Range("g29").Offset(j).Value = monBPU
Range("g29").Offset(j).NumberFormat = "_-* #,##0.00 [$-40C]_-;-* #,##0.00 [$-40C]_-;_-* ""-""?? [$-40C]_-;_-@_-"
Range("g29").Offset(j).EntireColumn.AutoFit
Range("h29").Offset(j).NumberFormat = "_-* #,##0.00 [$-40C]_-;-* #,##0.00 [$-40C]_-;_-* ""-""?? [$-40C]_-;_-@_-"
Range("h29").Offset(j).Value = monTPA
Range("h29").Offset(j).EntireColumn.AutoFit
Range("j29").Offset(j).NumberFormat = "_-* #,##0.00 [$-40C]_-;-* #,##0.00 [$-40C]_-;_-* ""-""?? [$-40C]_-;_-@_-"
Range("j29").Offset(j).Value = Range("f29").Offset(j).Value + Range("g29").Offset(j).Value + Range("h29").Offset(j).Value
Range("j29").Offset(j).EntireColumn.AutoFit
Range("k29").Offset(j).Value = TextBox7.Value
Range("k29").Offset(j).EntireColumn.AutoFit
Range("l29").Offset(j).Value = TextBox8.Value
Range("l29").Offset(j).EntireColumn.AutoFit
If ComboBox1.Value = "Marché" Then
Range("d9").Value = TextBox2.Value
Range("d10").Value = TextBox3.Value
Range("d18").Value = TextBox2.Value
Range("d24").Value = TextBox7.Value
Range("M12").Value = TextBox7.Value
Range("M13").Value = TextBox7.Value
End If
If ComboBox1.Value Like "Avenant *" Then
Range("f10").Value = TextBox3.Value
Range("f24").Value = TextBox7.Value
End If
Range("b29", "c29").Offset(j).Interior.ColorIndex = 37
Range("h29").Offset(j).Resize(1, 2).Merge
Range("l29").Offset(j).Resize(1, 5).Merge
For i = 0 To 12
Range("B29").Offset(j, i).Borders.Weight = xlThin
Next i
For h = 0 To nbrpt - 1
somPF = somPF + Range("f29").Offset(h).Value
somBPU = somBPU + Range("g29").Offset(h).Value
somTPA = somTPA + Range("h29").Offset(h).Value
Next h
Range("f29").Offset(nbrpt) = somPF
Range("g29").Offset(nbrpt) = somBPU
Range("h29").Offset(nbrpt) = somTPA
somTOT = somPF + somBPU + somTPA
Range("j29").Offset(nbrpt).NumberFormat = "_-* #,##0.00 [$-40C]_-;-* #,##0.00 [$-40C]_-;_-* ""-""?? [$-40C]_-;_-@_-"
Range("j29").Offset(nbrpt) = somTOT
TextBox2.Value = ""
TextBox6.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""
TextBox8.Value = ""
TextBox9.Value = ""
ComboBox1.Value = ""
description_du_contrat.Hide
Sheets("description du contrat").Activate
End Sub
Private Sub TextBox4_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr(1, "0123456789", Chr(KeyAscii)) = 0 And KeyAscii <> 8 Then
MsgBox "Saisir uniquement des caractères numériques"
KeyAscii = 0
End If
Dim Valeur As Byte
TextBox4.MaxLength = 4
End Sub
Private Sub TextBox5_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr(1, "0123456789", Chr(KeyAscii)) = 0 And KeyAscii <> 8 Then
MsgBox "Saisir uniquement des caractères numériques"
KeyAscii = 0
End If
End Sub
Private Sub TextBox6_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr(1, "0123456789", Chr(KeyAscii)) = 0 And KeyAscii <> 8 Then
MsgBox "Saisir uniquement des caractères numériques"
KeyAscii = 0
End If
End Sub
Private Sub TextBox7_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr(1, "0123456789", Chr(KeyAscii)) = 0 And KeyAscii <> 8 Then
MsgBox "Saisir uniquement des caractères numériques"
KeyAscii = 0
End If
End Sub
Private Sub TextBox7_Change()
' pour format xx/xx/xxxx
Dim Valeur As Byte
TextBox7.MaxLength = 10 'nb caracteres maxi dans textbox
Valeur = Len(TextBox7)
If Valeur = 2 Or Valeur = 5 Then TextBox7 = TextBox7 & "/"
End Sub
Private Sub TextBox9_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr(1, "0123456789", Chr(KeyAscii)) = 0 And KeyAscii <> 8 Then
MsgBox "Saisir uniquement des caractères numériques"
KeyAscii = 0
End If
End Sub
Private Sub UserForm_Activate()
If Sheets("description du contrat").Range("zz1").Value = "" Then
Exit Sub
Else:
ligne = Sheets("description du contrat").Range("zz1").Value
ComboBox1.Value = Range("b" & ligne).Value
TextBox2.Value = Range("c" & ligne).Value
TextBox3.Value = Range("D" & ligne).Value
TextBox4.Value = Right(Range("E" & ligne).Value, 4)
TextBox5 = Range("f" & ligne).Value
TextBox6 = Range("g" & ligne).Value
TextBox9 = Range("h" & ligne).Value
TextBox7.Value = Range("k" & ligne).Value
TextBox8.Value = Range("l" & ligne).Value
End If
End Sub |
Partager