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 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957
| Dim MyRange As Range
Private Sub CommandButton1_Click()
Dim LastRow As Range
Dim Response As Integer
If Me.TextBox14 = "" Or _
Me.TextBox2 = "" Then
MsgBox "Remplissez les données"
Exit Sub
End If
With Frame1
If Me.OptionButton1 = 0 And _
Me.OptionButton11 = 0 And _
Me.OptionButton2 = 0 And _
Me.OptionButton4 = 0 Then
MsgBox "Remplissez les données"
Exit Sub
End If
End With
With Frame2
If Me.OptionButton9 = 0 And _
Me.OptionButton10 = 0 Or _
Me.TextBox12 = "" Or _
Me.TextBox12 = 0 Then
MsgBox "Remplissez les données"
Exit Sub
End If
End With
With Frame3
If Me.OptionButton8 = 0 And _
Me.OptionButton7 = 0 Then
MsgBox "Remplissez les données"
Exit Sub
End If
If Me.OptionButton8 <> 0 And _
Me.TextBox5 = "" Then
MsgBox "Remplissez les données"
Exit Sub
End If
End With
With Sheets("Mouvementmatériels")
Set LastRow = Sheets("Mouvementmatériels").Range("D65536").End(xlUp)
If OptionButton1 = True Then
LastRow.Offset(1, 0).Value = TextBox9.Text
LastRow.Offset(1, -1).Value = OptionButton1.Tag
End If
If OptionButton2 = True Then
LastRow.Offset(1, 0).Value = TextBox10.Text
LastRow.Offset(1, -1).Value = OptionButton2.Tag
End If
If OptionButton4 = True Then
LastRow.Offset(1, 0).Value = TextBox11.Text
LastRow.Offset(1, -1).Value = OptionButton4.Tag
End If
If OptionButton11 = True Then
LastRow.Offset(1, 0).Value = TextBox19.Text
LastRow.Offset(1, -1).Value = OptionButton11.Tag
End If
If Me.OptionButton7 = True Then
LastRow.Offset(1, 1).Value = OptionButton7.Tag
End If
If Me.OptionButton8 = True Then
LastRow.Offset(1, 1).Value = OptionButton8.Tag
End If
If Me.OptionButton9 = True And _
Me.TextBox14.Text = Me.ListBox1.Text Then
LastRow.Offset(1, 7).Value = Now()
LastRow.Offset(1, 4).Value = ""
Sheets("BDD").Range("B" & Me.ListBox1.List(Me.ListBox1.ListIndex)) = Sheets("BDD").Range("B" & Me.ListBox1.List(Me.ListBox1.ListIndex)) + TextBox12.Value
End If
If Me.OptionButton10 = True And _
Me.TextBox14.Text = Me.ListBox1.Text Then
LastRow.Offset(1, 4).Value = Now()
LastRow.Offset(1, 7).Value = ""
Sheets("BDD").Range("B" & Me.ListBox1.List(Me.ListBox1.ListIndex)) = Sheets("BDD").Range("B" & Me.ListBox1.List(Me.ListBox1.ListIndex)) - TextBox12.Value
End If
End With
If Me.OptionButton9 = True Then
LastRow.Offset(1, 7).Value = Now()
LastRow.Offset(1, 4).Value = ""
End If
If Me.OptionButton10 = True Then
LastRow.Offset(1, 4).Value = Now()
LastRow.Offset(1, 7).Value = ""
End If
If Me.TextBox14.Text <> Me.ListBox1.Text Then
Set LastRow = Sheets("BDD").Range("a65536").End(xlUp)
LastRow.Offset(1, 0).Value = TextBox14.Text
LastRow.Offset(1, 1).Value = TextBox12.Value
LastRow.Offset(1, 2).Value = TextBox15.Value
LastRow.Offset(1, 3).Value = TextBox16.Value
End If
Set LastRow = Sheets("Mouvementmatériels").Range("a65536").End(xlUp)
LastRow.Offset(1, 0).Value = TextBox14.Text
LastRow.Offset(1, 5).Value = TextBox2.Text
LastRow.Offset(1, 6).Value = TextBox3.Text
LastRow.Offset(1, 8).Value = TextBox5.Text
LastRow.Offset(1, 11).Value = TextBox6.Text
LastRow.Offset(1, 1).Value = TextBox12.Text
LastRow.Offset(1, 13).Value = TextBox15.Text
If Me.TextBox14.Text = Me.ListBox1.Text Then
LastRow.Offset(1, 12).Value = TextBox7.Text
Else
LastRow.Offset(1, 12).Value = TextBox16.Text
End If
With Sheets("Ordredumouvement")
If OptionButton1 = True Then
Set LastRow = Sheets("Ordredumouvement").Range("a65536").End(xlUp)
LastRow.Offset(1, 0).Value = TextBox14.Text
LastRow.Offset(1, 1).Value = TextBox12.Text
LastRow.Offset(1, 2).Value = TextBox9.Text
LastRow.Offset(1, 3).Value = TextBox2.Text
LastRow.Offset(1, 4).Value = TextBox6.Text
LastRow.Offset(1, 5).Value = TextBox3.Text
End If
If OptionButton2 = True Then
Set LastRow = Sheets("Ordredumouvement").Range("g65536").End(xlUp)
LastRow.Offset(1, 0).Value = TextBox14.Text
LastRow.Offset(1, 1).Value = TextBox12.Text
LastRow.Offset(1, 2).Value = TextBox10.Text
LastRow.Offset(1, 3).Value = TextBox2.Text
LastRow.Offset(1, 4).Value = TextBox6.Text
LastRow.Offset(1, 5).Value = TextBox3.Text
End If
If OptionButton4 = True Then
Set LastRow = Sheets("Ordredumouvement").Range("m65536").End(xlUp)
LastRow.Offset(1, 0).Value = TextBox14.Text
LastRow.Offset(1, 1).Value = TextBox12.Text
LastRow.Offset(1, 2).Value = TextBox11.Text
LastRow.Offset(1, 3).Value = TextBox2.Text
LastRow.Offset(1, 4).Value = TextBox6.Text
LastRow.Offset(1, 5).Value = TextBox3.Text
End If
If OptionButton11 = True Then
Set LastRow = Sheets("Ordredumouvement").Range("s65536").End(xlUp)
LastRow.Offset(1, 0).Value = TextBox14.Text
LastRow.Offset(1, 1).Value = TextBox12.Text
LastRow.Offset(1, 2).Value = TextBox19.Text
LastRow.Offset(1, 3).Value = TextBox2.Text
LastRow.Offset(1, 4).Value = TextBox6.Text
LastRow.Offset(1, 5).Value = TextBox3.Text
End If
End With
Unload Me
End Sub
Private Sub CommandButton12_Click()
UserForm1.Hide
Sheets("Graphes").Select
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub CommandButton3_Click()
Unload Me
UserForm1.Show
End Sub
Private Sub CommandButton4_Click()
Dim Prem As String
Dim c As Range
With Me.ListBox1
.Clear
.ColumnCount = 2
.BoundColumn = 2
.ColumnWidths = "0;150"
End With
With Worksheets("BDD").UsedRange
Set c = .Find(Me.TextBox14, LookIn:=xlValues, Lookat:=xlPart)
If Not c Is Nothing Then
Prem = c.Address
Do
With Me.ListBox1
.AddItem c.Row
.List(.ListCount - 1, 1) = c.Offset(, 1 - c.Column)
End With
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> Prem
End If
End With
Me.TextBox12 = ""
Me.TextBox14 = ""
Me.TextBox15 = ""
Me.TextBox16 = ""
Me.TextBox8 = ""
Me.OptionButton9.Value = False
Me.OptionButton10.Value = False
Me.OptionButton8.Value = False
Me.OptionButton7.Value = False
Me.OptionButton1.Value = False
Me.OptionButton2.Value = False
Me.OptionButton4.Value = False
Me.OptionButton11.Value = False
For i = 0 To N - 1
If ListBox.Selected(i) Then
MsgBox "la valeur suivante est sélectionnée : " & ListBox.List(i)
End If
Next i
If ListBox1.ListCount = 0 Then
MsgBox "Ce matériel n'existe pas dans la base de données"
End If
End Sub
Private Sub CommandButton5_Click()
If ListBox1.ListIndex = -1 Then
MsgBox "Aucun matériel n'est sélectionné"
End If
If Me.ListBox1.ListIndex <> -1 Then
yourmsgbox = MsgBox("Veuillez confirmer la suppression définitive du matériel", vbOKCancel, "confirmation")
If yourmsgbox = vbCancel Then
Exit Sub
Else
Sheets("BDD").Rows(Me.ListBox1.List(Me.ListBox1.ListIndex)).EntireRow.Delete
End If
Unload Me
UserForm1.Show
End If
End Sub
Private Sub CommandButton6_Click()
If ListBox1.ListIndex = -1 Then
MsgBox "Aucun matériel n'est sélectionné"
End If
If Me.ListBox1.ListIndex <> -1 Then
Sheets("BDD").Activate
Sheets("BDD").Rows(Me.ListBox1.List(Me.ListBox1.ListIndex)).Activate
Unload Me
End If
End Sub
Private Sub CommandButton7_Click()
Application.ScreenUpdating = False
With Sheets("personnel").Select
ActiveSheet.Range("$A$2:$G$2788").AutoFilter Field:=1
ActiveSheet.Range("$A$2:$G$2788").AutoFilter Field:=2
ActiveWorkbook.Worksheets("personnel").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("personnel").AutoFilter.Sort.SortFields.Add Key:= _
Range("A1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("personnel").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
Worksheets("Mouvementmatériels").Select
i = 0
Me.ListBox2.Clear
Me.ListBox2.ColumnCount = 2
Me.ListBox2.BoundColumn = 2
Me.ListBox2.ColumnWidths = "0;150"
With Sheets("personnel")
.AutoFilterMode = False
Set plage = .Range(.[A2], .Cells(.Rows.Count, 1).End(xlUp)).Resize(, 1)
plage.AutoFilter 1, "*" & Me.TextBox2 & "*"
Set plage = plage.Offset(1).Resize(plage.Rows.Count - 1)
If Application.Subtotal(103, plage) > 0 Then
Set plage = plage.Resize(, 1).SpecialCells(xlCellTypeVisible)
For Each c In plage
Me.ListBox2.AddItem c.Row
Me.ListBox2.List(i, 1) = c.Value
i = i + 1
Next c
End If
.AutoFilterMode = False
End With
For i = 0 To N - 1
If ListBox.Selected(i) Then
MsgBox "la valeur suivante est sélectionnée : " & ListBox.List(i)
End If
Next i
If ListBox2.ListCount = 0 Then
MsgBox "Ce nom n'existe pas dans la base de données"
End If
Application.ScreenUpdating = True 'Facultatif
End Sub
Private Sub ListBox1_Change()
Me.ListBox3 = ""
ScrollBarQuantité.Value = ScrollBarQuantité.Min
ScrollBarQuantité.Enabled = False
If Me.ListBox1.ListIndex = -1 Then
Me.CommandButton6.Visible = False
Me.CommandButton5.Visible = False
End If
If Me.ListBox1.ListIndex <> -1 Then
Me.TextBox8 = Sheets("BDD").Range("B" & Me.ListBox1.List(Me.ListBox1.ListIndex))
Me.TextBox13 = Sheets("BDD").Range("E" & Me.ListBox1.List(Me.ListBox1.ListIndex))
Me.TextBox15 = Sheets("BDD").Range("C" & Me.ListBox1.List(Me.ListBox1.ListIndex))
Me.TextBox16 = Sheets("BDD").Range("D" & Me.ListBox1.List(Me.ListBox1.ListIndex))
Me.TextBox14.Text = Me.ListBox1.List(Me.ListBox1.ListIndex, 1)
Me.CommandButton6.Visible = True
Me.CommandButton5.Visible = True
End If
Me.TextBox12 = ""
Me.TextBox5 = ""
Me.ScrollBar2 = 0
Me.ScrollBar1 = 0
Me.OptionButton1 = 0
Me.OptionButton2 = 0
Me.OptionButton4 = 0
Me.OptionButton11 = 0
Me.OptionButton10 = 0
Me.OptionButton9 = 0
Me.OptionButton8 = 0
Me.OptionButton7 = 0
Me.TextBox9 = Application.WorksheetFunction.Max(Sheets("Ordredumouvement").Range("c3:c65536"))
Me.TextBox10 = Application.WorksheetFunction.Max(Sheets("Ordredumouvement").Range("i3:i65536"))
Me.TextBox11 = Application.WorksheetFunction.Max(Sheets("Ordredumouvement").Range("o3:o65536"))
Me.TextBox19 = Application.WorksheetFunction.Max(Sheets("Ordredumouvement").Range("u3:u65536"))
Me.TextBox2 = ""
Me.TextBox3 = ""
Me.TextBox6 = ""
Me.TextBox7 = ""
End Sub
Private Sub ListBox1_Click()
Me.ListBox3 = ""
ScrollBarQuantité.Value = ScrollBarQuantité.Min
ScrollBarQuantité.Enabled = False
End Sub
Private Sub ListBox1_Enter()
Me.ListBox3 = ""
ScrollBarQuantité.Enabled = False
ScrollBarQuantité.Value = ScrollBarQuantité.Min
End Sub
Private Sub ListBox2_Change()
If Me.ListBox2.ListIndex <> -1 Then
Me.TextBox3 = Sheets("personnel").Range("B" & Me.ListBox2.List(Me.ListBox2.ListIndex))
End If
ScrollBarQuantité.Value = ScrollBarQuantité.Min
ScrollBarQuantité.Enabled = False
End Sub
Private Sub ListBox2_Click()
If Me.ListBox2.ListIndex <> -1 Then
Me.TextBox2.Text = Me.ListBox2.Text
End If
ScrollBarQuantité.Value = ScrollBarQuantité.Min
ScrollBarQuantité.Enabled = False
End Sub
Private Sub ListBox2_Enter()
ListBox3 = ""
ScrollBarQuantité.Value = ScrollBarQuantité.Min
ScrollBarQuantité.Enabled = False
End Sub
Private Sub ListBox3_Enter()
Me.ListBox1 = ""
Me.ListBox2 = ""
End Sub
Private Sub OptionButton10_Change()
If Me.OptionButton9 = True Or _
Me.OptionButton10 = True Then
Frame1.Visible = True
Else
Frame1.Visible = False
End If
If Me.OptionButton10 = True Then
Me.OptionButton2.Enabled = False
Me.OptionButton2 = 0
Me.OptionButton4.Enabled = False
Me.OptionButton4 = 0
Else
Me.OptionButton2.Enabled = True
Me.OptionButton4.Enabled = True
End If
End Sub
Private Sub OptionButton7_Change()
If Me.OptionButton7 = True Then
Me.ScrollBar1 = 0
Me.TextBox5 = ""
Me.ScrollBar1.Enabled = False
Else
Me.ScrollBar1.Enabled = True
End If
End Sub
Private Sub OptionButton9_Change()
If Me.OptionButton9 = True Or _
Me.OptionButton10 = True Then
Frame1.Visible = True
Else
Frame1.Visible = False
End If
If TextBox14 = "" Then
Me.OptionButton9 = 0
End If
If Me.OptionButton9 = True Then
Me.OptionButton1.Enabled = False
Me.OptionButton1 = 0
Me.OptionButton11.Enabled = False
Me.OptionButton11 = 0
Else
Me.OptionButton1.Enabled = True
Me.OptionButton11.Enabled = True
End If
If Me.TextBox14.Text <> Me.ListBox1.Text And _
Me.OptionButton9 = True Then
UserForm2.Show
End If
End Sub
Private Sub ScrollBar1_Change()
Me.TextBox5 = Me.ScrollBar1
End Sub
Private Sub ScrollBar2_Change()
Me.TextBox12 = Me.ScrollBar2
End Sub
Private Sub TextBox14_Change()
ScrollBarQuantité.Value = ScrollBarQuantité.Min
ScrollBarQuantité.Enabled = False
If Me.OptionButton9 = True Or _
Me.OptionButton10 = True Then
Frame1.Visible = True
Else
Frame1.Visible = False
End If
Me.TextBox12 = ""
Me.TextBox5 = ""
Me.ScrollBar2 = 0
Me.ScrollBar1 = 0
Me.ListBox2 = ""
Me.TextBox9 = Application.WorksheetFunction.Max(Sheets("Ordredumouvement").Range("c3:c65536"))
Me.TextBox10 = Application.WorksheetFunction.Max(Sheets("Ordredumouvement").Range("i3:i65536"))
Me.TextBox11 = Application.WorksheetFunction.Max(Sheets("Ordredumouvement").Range("o3:o65536"))
Me.TextBox19 = Application.WorksheetFunction.Max(Sheets("Ordredumouvement").Range("u3:u65536"))
Me.TextBox2 = ""
Me.TextBox3 = ""
Me.TextBox6 = ""
Me.TextBox7 = ""
Me.TextBox9.Locked = True
Me.TextBox10.Locked = True
Me.TextBox11.Locked = True
Me.TextBox19.Locked = True
Me.TextBox2.Locked = True
Me.TextBox3.Locked = True
Me.TextBox6.Locked = True
Me.TextBox7.Locked = True
Me.ScrollBar2.Enabled = True
Me.ScrollBar1.Enabled = True
If Me.TextBox14 = ListBox1 Then
Me.TextBox15.Locked = True
Me.TextBox16.Locked = True
Me.TextBox15.BackColor = RGB(139, 139, 122)
Me.TextBox16.BackColor = RGB(139, 139, 122)
Me.TextBox13.Visible = True
Me.TextBox15.ForeColor = &HFFFFFF
Me.TextBox16.ForeColor = &HFFFFFF
Me.Label9.Visible = True
Me.TextBox7.Visible = True
Else
Me.TextBox13.Visible = False
Me.TextBox15 = ""
Me.TextBox15.Locked = False
Me.TextBox15.BackColor = &H80000005 'blanc
Me.TextBox15.ForeColor = &H0&
Me.TextBox16 = ""
Me.TextBox16.Locked = False
Me.TextBox16.BackColor = &H80000005 'blanc
Me.TextBox16.ForeColor = &H0&
Me.Label9.Visible = False
Me.TextBox7.Visible = False
Me.OptionButton10 = 0
Me.OptionButton9 = 0
Me.OptionButton8 = 0
Me.OptionButton7 = 0
Me.OptionButton1 = 0
Me.OptionButton2 = 0
Me.OptionButton4 = 0
Me.OptionButton11 = 0
Me.OptionButton10.Locked = True
End If
If Me.TextBox14.Text <> Me.ListBox1.Text Or _
Me.TextBox14 = "" Then
Me.OptionButton10.Locked = True
Else
Me.OptionButton10.Locked = False
End If
If Me.TextBox14 = "" Then
Me.OptionButton8.Locked = True
Me.OptionButton7.Locked = True
Me.OptionButton1.Locked = True
Me.OptionButton2.Locked = True
Me.OptionButton4.Locked = True
Me.OptionButton11.Locked = True
Me.ScrollBar2.Enabled = False
Me.ScrollBar1.Enabled = False
Me.CommandButton4.Visible = False
Else
Me.OptionButton8.Locked = False
Me.OptionButton7.Locked = False
Me.OptionButton1.Locked = False
Me.OptionButton2.Locked = False
Me.OptionButton4.Locked = False
Me.OptionButton11.Locked = False
Me.TextBox9.Locked = False
Me.TextBox10.Locked = False
Me.CommandButton4.Visible = True
Me.TextBox11.Locked = False
Me.TextBox19.Locked = False
Me.TextBox2.Locked = False
Me.TextBox3.Locked = False
Me.TextBox6.Locked = False
Me.TextBox7.Locked = False
End If
End Sub
Private Sub TextBox14_Enter()
ListBox3 = ""
ScrollBarQuantité.Enabled = False
ScrollBarQuantité.Value = ScrollBarQuantité.Min
End Sub
Private Sub TextBox2_Change()
If TextBox2 <> ListBox2 Then
Me.TextBox3 = ""
End If
End Sub
Private Sub UserForm_Activate()
ScrollBarQuantité.Value = ScrollBarQuantité.Min
ScrollBarQuantité.Enabled = False
Me.TextBox9 = Application.WorksheetFunction.Max(Sheets("Ordredumouvement").Range("c3:c65536"))
Me.TextBox10 = Application.WorksheetFunction.Max(Sheets("Ordredumouvement").Range("i3:i65536"))
Me.TextBox11 = Application.WorksheetFunction.Max(Sheets("Ordredumouvement").Range("o3:o65536"))
Me.TextBox19 = Application.WorksheetFunction.Max(Sheets("Ordredumouvement").Range("u3:u65536"))
If Me.TextBox14.Text <> Me.ListBox1.Text Or _
Me.TextBox14 = "" Then
Me.OptionButton10.Locked = True
Else
Me.OptionButton10.Locked = False
End If
If Me.TextBox14 = "" Then
Me.CommandButton4.Visible = False
Me.OptionButton8.Locked = True
Me.OptionButton7.Locked = True
Me.OptionButton1.Locked = True
Me.OptionButton2.Locked = True
Me.OptionButton4.Locked = True
Me.OptionButton11.Locked = True
Me.TextBox9.Locked = True
Me.TextBox10.Locked = True
Me.TextBox11.Locked = True
Me.TextBox19.Locked = True
Me.TextBox2.Locked = True
Me.TextBox3.Locked = True
Me.TextBox6.Locked = True
Me.TextBox7.Locked = True
Me.ScrollBar2.Enabled = False
Me.ScrollBar1.Enabled = False
End If
Set MyRange = Range("A2:j2", Range("A65536").End(xlUp))
ListBox3.RowSource = MyRange.Address
ListBox3.ListIndex = -1
ListBox3.ColumnWidths = "570;30;150;30;70;150;100;100;80;80"
ComboRef.ColumnWidths = "150;25"
End Sub
Private Sub CommandButton15_Click()
Dim Ligne
Ligne = ListBox3.ListIndex
If Ligne = False Or _
Me.TextBox1.Value = "" Or _
Me.TextBox1.Value = 0 Then
MsgBox "Il faut sélectionner l'item et la quantité rendu"
Exit Sub
UserForm1.Show
Else
'Msgbox Ok + Annuler
Select Case MsgBox("Veuillez confirmer que le matériel est rendu", vbOKCancel, "Demande de confirmation")
Case vbOK
'procédure si click sur Ok
With MyRange
Sheets("BDD").Range("B" & Me.ComboRef.ListIndex + 3) = Sheets("BDD").Range("B" & Me.ComboRef.ListIndex + 3) + Me.TextBox1.Value
.Rows(Ligne + 1).EntireRow.Delete
End With
Case vbCancel
'procédure si click sur Annuler
Exit Sub
UserForm1.Show
End Select
End If
End Sub
Private Sub CommandButton14_Click()
Dim Ligne
Ligne = ListBox3.ListIndex
If Ligne = False Or _
Me.TextBox1.Value = "" Or _
Me.TextBox1.Value = 0 Then
MsgBox "Il faut sélectionner l'item et la quantité rendu"
Exit Sub
UserForm1.Show
Else
'Msgbox Ok + Annuler
Select Case MsgBox("Veuillez confirmer que le matériel est rendu", vbOKCancel, "Demande de confirmation")
Case vbOK
'procédure si click sur Ok
With MyRange
Sheets("BDD").Range("B" & Me.ComboRef.ListIndex + 3) = Sheets("BDD").Range("B" & Me.ComboRef.ListIndex + 3) + Me.TextBox1.Value
Sheets("Mouvementmatériels").Range("B" & Me.ListBox3.ListIndex + 2) = Me.TextBox17.Value
End With
Case vbCancel
'procédure si click sur Annuler
Exit Sub
UserForm1.Show
End Select
End If
End Sub
Private Sub CommandButton16_Click()
Dim Ligne
Ligne = ListBox3.ListIndex
If Ligne = False Or _
Me.TextBox1.Value = "" Or _
Me.TextBox1.Value = 0 Then
MsgBox "Il faut sélectionner l'item et la quantité rendu"
Exit Sub
UserForm1.Show
Else
'Msgbox Ok + Annuler
Select Case MsgBox("Veuillez confirmer que le matériel est rendu", vbOKCancel, "Demande de confirmation")
Case vbOK
'procédure si click sur Ok
With MyRange
Sheets("Mouvementmatériels").Range("B" & Me.ListBox3.ListIndex + 2) = Me.TextBox17.Value
End With
UserForm2.Show
With Sheets("BDD")
Dim LastRow As Range
Dim Response As Integer
Set LastRow = Sheets("BDD").Range("a65536").End(xlUp)
LastRow.Offset(1, 2).Value = TextBox15.Text
LastRow.Offset(1, 3).Value = TextBox16.Text
LastRow.Offset(1, 0).Value = TextBox18.Text
LastRow.Offset(1, 1).Value = TextBox1.Text
End With
Case vbCancel
'procédure si click sur Annuler
Exit Sub
UserForm1.Show
End Select
End If
End Sub
Private Sub CommandButton13_Click()
Dim Ligne
Ligne = ListBox3.ListIndex
If Ligne = False Or _
Me.TextBox1.Value = "" Or _
Me.TextBox1.Value = 0 Then
MsgBox "Il faut sélectionner l'item et la quantité rendu"
Exit Sub
UserForm1.Show
Else
'Msgbox Ok + Annuler
Select Case MsgBox("Veuillez confirmer que le matériel est rendu", vbOKCancel, "Demande de confirmation")
Case vbOK
'procédure si click sur Ok
UserForm2.Show
With Sheets("BDD")
Dim LastRow As Range
Dim Response As Integer
Set LastRow = Sheets("BDD").Range("a65536").End(xlUp)
LastRow.Offset(1, 2).Value = TextBox15.Text
LastRow.Offset(1, 3).Value = TextBox16.Text
LastRow.Offset(1, 0).Value = TextBox18.Text
LastRow.Offset(1, 1).Value = TextBox1.Text
End With
With MyRange
.Rows(Ligne + 1).EntireRow.Delete
End With
Case vbCancel
'procédure si click sur Annuler
Exit Sub
UserForm1.Show
End Select
End If
End Sub
Private Sub ListBox3_Change()
Me.ListBox1 = ""
Me.ListBox2 = ""
If ListBox3.ListIndex = -1 Then
ScrollBarQuantité.Value = ScrollBarQuantité.Min
End If
Me.TextBox14 = ""
Me.TextBox15.Locked = True
Me.TextBox16.Locked = True
Me.TextBox15.Locked = True
Me.TextBox16.Locked = True
Me.TextBox15.BackColor = RGB(139, 139, 122)
Me.TextBox16.BackColor = RGB(139, 139, 122)
Me.TextBox15.ForeColor = &HFFFFFF
Me.TextBox16.ForeColor = &HFFFFFF
Me.ScrollBarQuantité.Enabled = True
TextBox18.Text = Sheets("Mouvementmatériels").Range("A" & Me.ListBox3.ListIndex + 2)
Me.TextBox17.Value = Sheets("Mouvementmatériels").Range("B" & Me.ListBox3.ListIndex + 2) - Me.ScrollBarQuantité
End Sub
Private Sub ListBox3_Click()
Me.ListBox1 = ""
Me.ListBox2 = ""
ComboRef.Text = ListBox3.Text
If ComboRef.Text = Sheets("BDD").Range("A" & Me.ComboRef.ListIndex + 3) Then
Me.TextBox8 = Sheets("BDD").Range("B" & Me.ComboRef.ListIndex + 3)
Me.TextBox15 = Sheets("BDD").Range("C" & Me.ComboRef.ListIndex + 3)
Me.TextBox16 = Sheets("BDD").Range("D" & Me.ComboRef.ListIndex + 3)
Me.TextBox13 = Sheets("BDD").Range("E" & Me.ComboRef.ListIndex + 3)
End If
If ComboRef.Text <> Sheets("BDD").Range("A" & Me.ComboRef.ListIndex + 3) Then
Me.TextBox8 = 0 And _
Me.TextBox13.Visible = False
Me.TextBox13.Visible = False
Me.TextBox15 = Sheets("Mouvementmatériels").Range("N" & Me.ListBox3.ListIndex + 2)
Me.TextBox16 = Sheets("Mouvementmatériels").Range("M" & Me.ListBox3.ListIndex + 2)
Else
Me.TextBox13.Visible = True
Me.TextBox13.Visible = True
End If
Dim Ligne
Ligne = ListBox3.ListIndex
If Ligne = False Then
MsgBox "Il faut sélectionner l'item ou la quantité rendu"
Me.CommandButton15.Visible = False
Me.CommandButton13.Visible = False
Me.CommandButton14.Visible = False
Me.CommandButton16.Visible = False
Unload Me
UserForm1.Show
Else
With MyRange
If ComboRef.Text = Sheets("BDD").Range("A" & Me.ComboRef.ListIndex + 3) And _
Me.TextBox17.Value <= 0 Then
Me.CommandButton15.Visible = True
Me.CommandButton13.Visible = False
Me.CommandButton14.Visible = False
Me.CommandButton16.Visible = False
End If
If ComboRef.Text <> Sheets("BDD").Range("A" & Me.ComboRef.ListIndex + 3) And _
Me.TextBox17.Value <= 0 Then
Me.CommandButton13.Visible = True
Me.CommandButton15.Visible = False
Me.CommandButton14.Visible = False
Me.CommandButton16.Visible = False
End If
If ComboRef.Text = Sheets("BDD").Range("A" & Me.ComboRef.ListIndex + 3) And _
Me.TextBox17.Value > 0 Then
Me.CommandButton14.Visible = True
Me.CommandButton13.Visible = False
Me.CommandButton15.Visible = False
Me.CommandButton16.Visible = False
End If
If ComboRef.Text <> Sheets("BDD").Range("A" & Me.ComboRef.ListIndex + 3) And _
Me.TextBox17.Value > 0 Then
Me.CommandButton16.Visible = True
Me.CommandButton13.Visible = False
Me.CommandButton15.Visible = False
Me.CommandButton14.Visible = False
End If
End With
End If
End Sub
Private Sub ScrollBarQuantité_Change()
Me.TextBox1 = Me.ScrollBarQuantité
Me.TextBox17.Value = Sheets("Mouvementmatériels").Range("B" & Me.ListBox3.ListIndex + 2) - Me.ScrollBarQuantité
End Sub
Private Sub TextBox17_Change()
Dim Ligne
Ligne = ListBox3.ListIndex
With MyRange
If ComboRef.Text = Sheets("BDD").Range("A" & Me.ComboRef.ListIndex + 3) And _
Me.TextBox17.Value <= 0 Then
Me.CommandButton15.Visible = True
Me.CommandButton13.Visible = False
Me.CommandButton14.Visible = False
Me.CommandButton16.Visible = False
End If
If ComboRef.Text <> Sheets("BDD").Range("A" & Me.ComboRef.ListIndex + 3) And _
Me.TextBox17.Value <= 0 Then
Me.CommandButton13.Visible = True
Me.CommandButton15.Visible = False
Me.CommandButton14.Visible = False
Me.CommandButton16.Visible = False
End If
If ComboRef.Text = Sheets("BDD").Range("A" & Me.ComboRef.ListIndex + 3) And _
Me.TextBox17.Value > 0 Then
Me.CommandButton14.Visible = True
Me.CommandButton13.Visible = False
Me.CommandButton15.Visible = False
Me.CommandButton16.Visible = False
End If
If ComboRef.Text <> Sheets("BDD").Range("A" & Me.ComboRef.ListIndex + 3) And _
Me.TextBox17.Value > 0 Then
Me.CommandButton16.Visible = True
Me.CommandButton13.Visible = False
Me.CommandButton15.Visible = False
Me.CommandButton14.Visible = False
End If
End With
End Sub |
Partager