Error al seleccionar dato de listbox no resta los valores
@hola tengo el siguiente en un listbox
Private Sub ListBox1_Click() If Me.ListBox1.List(ListBox1.ListIndex, 5) > Sheets(Hoja1.Name).[C1] Then MsgBox "Se paso de su hora de comida por " & Format(Me.ListBox1.List(ListBox1.ListIndex, 5) - Sheets(Hoja1.Name).[C1], "hh:mm") & " min" _ & vbCr & Format(Me. ListBox1. List(ListBox1.ListIndex, 6), "dd/mm/yyyy"), , Me. ListBox1. List(ListBox1. ListIndex, 0) End If End Sub
el cual me funciona excelente
Pero al utilizar un codigo en el evento change del textbox 1 y ejecutar de nuevo el codigo de arriba me sale error
este es el codigo del textbox
Private Sub TextBox1_Change()
Application.ScreenUpdating = False
TextBox1.Value = UCase(TextBox1) 'cambiar # de textbox
Set b = Sheets("HISTORIA.L")
uf = b.Range("B" & Rows.Count).End(xlUp).Row
Me.ListBox1.RowSource = ""
With ListBox1
.ColumnCount = 13
.List = Range("B3:Q3").Value
.ColumnWidths = "200 pt;150 pt;50 pt;60 pt;60 pt;50 pt;80 pt;60 pt;60 pt;60 pt;80 pt;80 pt;80 pt" 'asignando ancho de columnas
.Clear
For i = 4 To b.Range("B3").End(xlDown).Row
'
strg = b.Cells(i, 3).Value 'cambiar # de columna a buscar
If UCase(strg) Like "*" & UCase(TextBox1.Value) & "*" Then 'cambiar # de textbox
. AddItem
. List(.ListCount - 1, 0) = b. Cells(i, 3) ' nombre
. List(.ListCount - 1, 1) = b. Cells(i, 4) ' area
. List(.ListCount - 1, 2) = b. Cells(i, 5) ' incidencia SC
. List(.ListCount - 1, 3) = Format(b. Cells(i, 6), "hh:mm am/pm") ' hora de salida a comer
. List(.ListCount - 1, 4) = Format(b. Cells(i, 7), "hh:mm am/pm") ' hora de entrada a comer
. List(.ListCount - 1, 5) = Format(b. Cells(i, 8), "hh:mm") 'minutos generados
. List(.ListCount - 1, 6) = b. Cells(i, 9) ' fecha del dia
. List(.ListCount - 1, 7) = Format(b. Cells(i, 10), "MMMM") ' mes
. List(.ListCount - 1, 8) = b. Cells(i, 11) ' semana
. List(.ListCount - 1, 9) = b. Cells(i, 12) 'incidencia EC
. List(.ListCount - 1, 10) = Format(b. Cells(i, 13), "hh:mm am/pm") 'HORA ENTRADA
. List(.ListCount - 1, 11) = Format(b. Cells(i, 14), "hh:mm am/pm") 'HORA SALIDA
. List(.ListCount - 1, 12) = Format(b. Cells(i, 15), "hh:mm") ' JORNADA REALIZADA
End If
Next i
End With
If ListBox1.ListCount > 0 Then
TextBox2.Value = Empty
TextBox3.Value = Empty
TextBox4.Value = Empty
'MsgBox "si"
Else
MsgBox "Si No Se Encuentra el COLABORADOR " & TextBox1.Value & " Puede Ser Por: 1.- No Esta Registrado En La Base De Datos O 2.- La Busqueda Es Incorrecta. Intenta de Nuevo", vbExclamation, "INFORMACIÓN UTIL"
TextBox1.Value = Empty
End If
Me.ListBox1.ColumnWidths = "200 pt;150 pt;50 pt;60 pt;60 pt;50 pt;80 pt;60 pt;60 pt;60 pt;80 pt;80 pt;80 pt"
End Subque hago mal me podrian orientar
1 Respuesta
Respuesta de Programar Excel
1