Ver Mensaje Individual
  #3 (permalink)  
Antiguo 24/02/2012, 09:33
Avatar de alexmtz
alexmtz
 
Fecha de Ingreso: febrero-2012
Ubicación: cancun
Mensajes: 5
Antigüedad: 12 años, 2 meses
Puntos: 0
Pregunta Respuesta: contador en macro Excel

gracias por responder, ok, mira ahi te va, tengo 3 user form, te voy a pasar el de la captura principal, la mayoria de los codigos los he ido adecuando conforme los he necesitado de ejemplos que he visto, ahora como te decis solo tengo que agregar un contador que cuando llegue a las 500 capturas de etiquetas se detenga, saludos

Private Sub cmdCaptura_Click()

On Error Resume Next

'aqui verificamos que los texts no esten vacios
If Me.txtEtiqueta.Text = "" Then MsgBox "El Numero de Etiqueta no puede estar vacio", _
vbExclamation, "CONTROL DE BOTELLAS": Exit Sub
If Me.txtCodigo.Text = "" Then MsgBox "El Codigo de Botella no puede estar vacio", _
vbExclamation, "CONTROL DE BOTELLAS": Exit Sub

Range("A1").Activate
'inicia la busqueda en la columna A
[a1:a1010].Find(What:=txtEtiqueta, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
'si encontro el valor se posiciona
ActiveCell.Offset(0, 0).Select
'pregunta si la posicion del valor buscado esta vacio
If Selection.Offset().Value <> "" Then
'si no esta vacia le dice k ya hay registro
MsgBox "Esta etiqueta ya fue capturada", vbExclamation, "CONTROL DE BOTELLAS"
Else

' si todo esta bien entonces insertamos los datos en la hoja
If Sheets("HISTORIA").Range("A5").Value = "" Then
' si no hay ningun registro todavia
Sheets("HISTORIA").Range("A5").Value = Me.txtEtiqueta.Text
Sheets("HISTORIA").Range("B5").Value = Me.txtCodigo.Text
MsgBox "Te informo que el NUMERO DE ETIQUETA es ahora el numero de tu BOTELLA", _
vbExclamation, "CONTROL DE BOTELLAS"
Range("A7").Select
Selection.End(xlDown).Select
Selection.Offset(0, 4).Select
ActiveCell.FormulaR1C1 = Date

Else
' a partir dl segundo registro
Sheets("HISTORIA").Range("A4").End(xlDown)(xlDropD own).Value = Me.txtEtiqueta.Text
Sheets("HISTORIA").Range("A4").End(xlDown).Next.Va lue = Me.txtCodigo.Text
MsgBox "Recuerda, el NUMERO DE ETIQUETA es ahora el numero de tu BOTELLA", _
vbExclamation, "CONTROL DE BOTELLAS"
Range("A4").Select
Selection.End(xlDown).Select
Selection.Offset(0, 4).Select
ActiveCell.FormulaR1C1 = Date

End If

End If
' limpiamos el formulario para la siguiente captura
Me.txtEtiqueta.Text = ""
Me.txtCodigo.Text = ""

' ponemos el cursor en el primer campo de captura
Me.txtEtiqueta.SetFocus

Range("A4").Select
Selection.End(xlDown).Select
End Sub