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
| Private Sub CommandButton1_Click()
Dim Dossier As String * 5
Dim Nocli As Integer
Dim Sequence As String * 8
Dim Client As String
Dim Chantier As String
Dim Poids As Currency
Dim Emplac As String * 1
Dim Nodoss As String * 2
Dim Noseq As String * 4
Nodoss = TextBox1
Nocli = TextBox2
Noseq = TextBox3
Dossier = "CHT" & Nodoss
Sequence = "SEQ-" & Noseq
Dim VC1 As String * 5
Dim VC2 As Integer
Dim VC3 As String * 8
Dim Compt As Integer
Client = " "
Chantier = " "
Emplac = " "
' ***** RECHERCHE DE LA SELECTION UTILISATEUR
Range("A1").Select
For Compt = 1 To 1000
VC1 = ActiveCell.Offset(Compt, 0).Value
VC2 = ActiveCell.Offset(Compt, 1).Value
VC3 = ActiveCell.Offset(Compt, 2).Value
If VC1 = Dossier Then
If VC2 = Nocli Then
If VC3 = Sequence Then
Client = ActiveCell.Offset(Compt, 3).Value
Chantier = ActiveCell.Offset(Compt, 4).Value
Poids = ActiveCell.Offset(Compt, 5).Value
If ActiveCell.Offset(Compt, 6).Value <> "" Then
Emplac = ActiveCell.Offset(Compt, 6).Value
End If
ActiveCell.Offset(Compt, 6).Select
Compt = 1000
End If
End If
End If
Next Compt
' ***** SI TROUVÉ, AFFICHAGE DES DONNÉS DANS USERFORM2
If Client <> " " Then
GoTo Affich_Form2
End If
' ***** SI PAS TROUVÉ, RECHERCHE DANS LE CLASSEUR LISTE - TRANSPORT
Workbooks.Open Filename:="V:\liste - transport 2005.xls"
Sheets("2005").Select
Range("A2").Select
For Compt = 1 To 10000
VC1 = ActiveCell.Offset(Compt, 7).Value
VC2 = ActiveCell.Offset(Compt, 8).Value
VC3 = ActiveCell.Offset(Compt, 9).Value
If VC1 = Dossier Then
If VC2 = Nocli Then
If VC3 = Sequence Then
Client = ActiveCell.Offset(Compt, 1).Value
Chantier = ActiveCell.Offset(Compt, 2).Value
Poids = ActiveCell.Offset(Compt, 10).Value
Compt = 10000
End If
End If
End If
Next Compt
ActiveWindow.Close
If Client = " " And Chantier = " " Then
MsgBox "AUCUNE REFERENCE TROUVÉE", 48, "***** ERREUR *****"
TextBox3.SetFocus
GoTo Erreur
End If
Range("A1001").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Value = Dossier
ActiveCell.Offset(1, 1).Value = Nocli
ActiveCell.Offset(1, 2).Value = Sequence
ActiveCell.Offset(1, 3).Value = Client
ActiveCell.Offset(1, 4).Value = Chantier
ActiveCell.Offset(1, 5).Value = Poids
ActiveCell.Offset(1, 6).Select
ActiveWorkbook.Save
Affich_Form2:
Application.ScreenUpdating = True
Unload UserForm1
UserForm2.TextBox1 = Dossier
UserForm2.TextBox2 = Nocli
UserForm2.TextBox3 = Sequence
UserForm2.TextBox4 = Client
UserForm2.TextBox5 = Chantier
UserForm2.TextBox6 = Poids
If Emplac <> " " Then
UserForm2.TextBox7 = Emplac
End If
UserForm2.Show
Application.ScreenUpdating = False
Erreur:
End Sub |
Partager