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
|
Private Sub UserForm_Initialize()
AffBox.Show 0
End Sub
Private Sub CodeBarre_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyReturn Then
If CodeBarre.Text <> "" Then
Recherche (CodeBarre.Text)
End If
End If
End Sub
Sub Recherche(CodeARechercher As String)
Dim Code As Range, Magasin As Range, F1 As Worksheet, c As Range, m As Range
Set F1 = Sheets("Feuille 1")
Set Code = F1.Range("A2:A" & F1.Range("A" & Rows.Count).End(xlUp).Row)
Set Magasin = F1.Range("D2:D" & F1.Range("D" & Rows.Count).End(xlUp).Row)
Set c = Code.Find(CodeARechercher, LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
Article = c.Cells.Offset(0, 1)
Set m = Magasin.Find(Article, LookIn:=xlValues, lookat:=xlWhole)
If Not m Is Nothing Then
Box.Text = m.Cells.Offset(0, 1)
c.Cells.Offset(0, 2) = m.Cells.Offset(0, 1)
Else
Box.Text = "Magasin non trouvé"
End If
Else
Box.Text = "Code non trouvé"
End If
AffBox.LbBox.Caption = Box.Text
Delai CInt(Tempo.Text)
Box.Text = ""
AffBox.LbBox.Caption = Box.Text
CodeBarre.Text = ""
CodeBarre.SetFocus
End Sub
Private Sub CmdRAZ_Click()
CodeBarre.Text = ""
Box.Text = ""
AffBox.LbBox.Caption = ""
End Sub
Private Sub UserForm_Terminate()
Unload AffBox
End Sub |