Ejecutar modulo al presionar el decimo digito en textbox
Hola Dan .. Hace unas horas me ayudo con un código el cual le agradezco.. Pero me gustaría agregar un código que tengo en un modulo al presionar el digito numero 10 que seria al terminar de escribir una fecha ejemplo de fecha 13/05/2018 ejecute el modulo .. Todo esto para ver si es valida la fecha o no .
Lo que he leído que al escribir una fecha no valida es como escribir un texto .
Por favor Dan
Saludos
Este es el modulo código
Sub validar()
Dim Valor As Variant
Valor = UserForm1.Txt_DTPicker1.Value
Select Case True
Case IsDate(Valor)
Case WorksheetFunction.IsText(Valor)
MsgBox ("No es fecha valida.")
UserForm1.Txt_DTPicker1.SetFocus
End Select
End SubPrivate Sub txt_DTPicker1_Change()
lbltotal = ""
ListBox1.Clear
Dim fec As Date
' Dim Valor As Variant
'Valor = UserForm1.Txt_DTPicker1.Value
If Txt_DTPicker1 = "" Or Not IsDate(Txt_DTPicker1) Or _
Len(Txt_DTPicker1) < 10 Or Len(Txt_DTPicker1) > 10 Then
Exit Sub
End If
ListBox1.ColumnCount = 8
ListBox1.ColumnWidths = "60;200;60;90;90;120;90;90"
For i = 2 To Hoja4.Range("A" & Rows.Count).End(xlUp).Row
fec = Format(Hoja4.Cells(i, "D"), "dd/mm/yyyy")
If fec = Txt_DTPicker1.Value Then
existe = False
If Hoja4.Cells(i, "G") > 0.0001 Then
For j = 0 To ListBox1.ListCount - 1
If IsNumeric(ListBox1.List(j)) Then vmate = CDbl(ListBox1.List(j)) Else vmate = ListBox1.List(j)
If IsNumeric(ListBox1.List(j, 3)) Then vlote = CDbl(ListBox1.List(j, 3)) Else vlote = ListBox1.List(j, 3)
'
If vmate = Hoja4.Cells(i, "A") And vlote = Hoja4.Cells(i, "B") Then
ListBox1.List(j, 6) = Format(CDbl(ListBox1.List(j, 6)) + Hoja4.Cells(i, "G"), "#,##0.000")
existe = True
Exit For
End If
Next
If existe = False Then agregar i, Hoja4
End If
End If
Next
If ListBox1.ListCount = 0 Then
MsgBox "No hay registros que cumplan la condición"
End If
End Sub
1 respuesta
Respuesta de Dante Amor
1
