UserForm y codigo de barras ausencia de mensaje de error!!

Solo consultas sobre macros y código VBA Excel.

Reglas del Foro
1. Antes de hacer tu pregunta intenta con el buscador de este foro (muchas preguntas ya fueron respondidas antes!)
2. Si haces una nueva pregunta, es muy recomendable que adjuntes el ejemplo Excel para poder comprenderla mejor!
3. Realiza tu pregunta de forma clara, explicando bien cada paso de lo que haces y tendrás más probabilidad de respuesta!
Compartir en:
     

UserForm y codigo de barras ausencia de mensaje de error!!

Notapor maribel135 » 02 Feb 2012 13:58

Buenas tardes, tengo esta macro en la que ingreso con una maquina para escanear diferentes codigos de barras, resulta que el valor que me ingresa la maquinita puede ser:
12345
04566
q6712345q
q6702345q
q6700345q

entonces tiene que ir con ese numero a buscar en la base de datos el numero exacto, pero en la base de datos lo que yo tengo para cada ingreso respectivamente es:

12345
4566 (sin el 0)
12345 (sin q y sin 67)
2345
345

en las dos ultimas de nuevo sin los 0, por lo que hice la macro que adjunto!! Eso funciona!! Sin embargo el error que tengo es que existen ciertos codigos que NO estan en la base de datos y sin embargo no me envia el mensaje de error que puse al final...

Podrian por favor ayudarme????

Desde ya muchas gracias

Private Sub Z_saisie_AfterUpdate()

Dim Valeur As String
Dim r As Range

Debug.Print Z_saisie.Value 'codigo poitrine de 5 cifras
Valeur = Z_saisie.Value


If Trim(Valeur) <> "" Then
With Feuil1.Range("A:L")
Set r = .Find(What:=Valeur, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If Not r Is Nothing And ob_entrée.Value = True Then

Feuil6.Select
Range("C3:D3").Select
Selection.Copy

Application.Goto r, True

ActiveCell.Offset(0, 3).Select

ActiveSheet.Paste

End If


If Not r Is Nothing And ob_sortie.Value = True Then

Feuil6.Select
Range("C3:D3").Select
Selection.Copy

Application.Goto r, True

ActiveCell.Offset(0, 7).Select

ActiveSheet.Paste

End If

If r Is Nothing Then

Z_saisie.Value = Mid(Z_saisie, 2, 7) 'codigo poitrine de 4 cifras

Debug.Print Z_saisie.Value
Valeur = Z_saisie.Value


If Trim(Valeur) <> "" Then
With Feuil1.Range("A:L")
Set r = .Find(What:=Valeur, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If Not r Is Nothing And ob_entrée.Value = True Then

Feuil6.Select
Range("C3:D3").Select
Selection.Copy

Application.Goto r, True

ActiveCell.Offset(0, 3).Select

ActiveSheet.Paste

End If


If Not r Is Nothing And ob_sortie.Value = True Then

Feuil6.Select
Range("C3:D3").Select
Selection.Copy

Application.Goto r, True

ActiveCell.Offset(0, 7).Select

ActiveSheet.Paste

End If

If r Is Nothing Then

Z_saisie.Value = Mid(Z_saisie, 3, 5) 'codigo poignet de 5 cifras

Debug.Print Z_saisie.Value
Valeur = Z_saisie.Value


If Trim(Valeur) <> "" Then
With Feuil1.Range("A:L")
Set r = .Find(What:=Valeur, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If Not r Is Nothing And ob_entrée.Value = True Then

Feuil6.Select
Range("C3:D3").Select
Selection.Copy

Application.Goto r, True

ActiveCell.Offset(0, 3).Select

ActiveSheet.Paste

End If


If Not r Is Nothing And ob_sortie.Value = True Then

Feuil6.Select
Range("C3:D3").Select
Selection.Copy

Application.Goto r, True

ActiveCell.Offset(0, 7).Select

ActiveSheet.Paste

End If

If r Is Nothing Then

Z_saisie.Value = Mid(Z_saisie, 2, 5) 'codigo poignet 4 cifras 1382

Debug.Print Z_saisie.Value
Valeur = Z_saisie.Value


If Trim(Valeur) <> "" Then
With Feuil1.Range("A:L")
Set r = .Find(What:=Valeur, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If Not r Is Nothing And ob_entrée.Value = True Then

Feuil6.Select
Range("C3:D3").Select
Selection.Copy

Application.Goto r, True

ActiveCell.Offset(0, 3).Select

ActiveSheet.Paste

End If


If Not r Is Nothing And ob_sortie.Value = True Then

Feuil6.Select
Range("C3:D3").Select
Selection.Copy

Application.Goto r, True

ActiveCell.Offset(0, 7).Select

ActiveSheet.Paste

End If

If r Is Nothing Then

Z_saisie.Value = Mid(Z_saisie, 2, 5) 'codigo poignet de 3 cifras 382
Debug.Print Z_saisie.Value
Valeur = Z_saisie.Value


If Trim(Valeur) <> "" Then
With Feuil1.Range("A:L")
Set r = .Find(What:=Valeur, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If Not r Is Nothing And ob_entrée.Value = True Then

Feuil6.Select
Range("C3:D3").Select
Selection.Copy

Application.Goto r, True

ActiveCell.Offset(0, 3).Select

ActiveSheet.Paste

End If


If Not r Is Nothing And ob_sortie.Value = True Then

Feuil6.Select
Range("C3:D3").Select
Selection.Copy

Application.Goto r, True

ActiveCell.Offset(0, 7).Select

ActiveSheet.Paste

End If

If r Is Nothing Then

Message = MsgBox("El valor no se ha encontrado", vbInformation)

End If

End With
End If
End If
End With
End If
End If

End With

End If

End If

End With

End If

End If

End With

End If



Z_saisie.Value = ""


Feuil5.Activate


End Sub
* Te recomendamos estos productos Excel: Manual de Macros | Manual de Funciones | Nuevas Funciones | ddTraDa
maribel135
Miembro Nuevo
Miembro Nuevo
 
Registrado: 02 Feb 2012 13:48

Compartir en:
     

  • Anuncio
Manual Excel avanzado

Volver a Macros

¿Quién está conectado?

Usuarios navegando por este Foro: botesponja, cjadeva, sonkanon y 5 invitados