Cambiar código de textbox que llena listbox a listview
¿Hola Dan como estas?
Me podrías ayudar con esto por favor .. Tengo un textbox que al escribir busca la palabra exacta o con la letra que empieza y trae los datos al listbox pero ya no quiero ocupar el listbox .. Quiero ocupar un listview
Este es el código
¿Cómo se pasaría de listbox a listview?
Por favor dan gracias
Private Sub txtbuscar_Change()
Application.ScreenUpdating = False
Lb_buscar.Clear
Lb_buscar.ColumnCount = 7
Lb_buscar.ColumnWidths = "60;100;90;80;120;130"
For i = 2 To Hoja3.Range("A" & Rows.Count).End(xlUp).Row
cadena = UCase(Hoja3.Cells(i, 1))
If cadena Like "*" & UCase(txtbuscar) & "*" And Hoja3.Cells(i, "A") <> 0 Then
existe = False
'
For j = 0 To Lb_buscar.ListCount - 1
If Hoja3.Cells(i, "A").Text = Lb_buscar.List(j) Then
Lb_buscar.List(j, 1) = Hoja3.Cells(i, "W").Value
Lb_buscar.List(j, 2) = Hoja3.Cells(i, "AA").Value
Lb_buscar.List(j, 3) = Lb_buscar.List(j, 2) - Lb_buscar.List(j, 1)
Lb_buscar.List(j, 5) = DateAdd("yyyy", 1, Hoja3.Cells(i, "X").Value)
existe = True
Exit For
End If
Next
If existe = False Then
''''''''''''''''''''''
Lb_buscar.AddItem Hoja3.Cells(i, "A").Value
'
Lb_buscar.List(Lb_buscar.ListCount - 1, 1) = Hoja3.Cells(i, "W").Value
Lb_buscar.List(Lb_buscar.ListCount - 1, 2) = Hoja3.Cells(i, "AA").Value
Lb_buscar.List(Lb_buscar.ListCount - 1, 3) = Lb_buscar.List(Lb_buscar.ListCount - 1, 2) - Lb_buscar.List(Lb_buscar.ListCount - 1, 1)
'''''''''''''''''
Lb_buscar.List(Lb_buscar.ListCount - 1, 4) = Hoja3.Cells(i, "X").Value
If Hoja3.Cells(i, "Y") <> 0 Then
Lb_buscar.List(Lb_buscar.ListCount - 1, 5) = DateAdd("yyyy", 1, Lb_buscar.List(Lb_buscar.ListCount - 1, 4))
Else
Lb_buscar.List(Lb_buscar.ListCount - 1, 5) = DateAdd("yyyy", 1, Lb_buscar.List(Lb_buscar.ListCount - 1, 4))
Lb_buscar.List(Lb_buscar.ListCount - 1, 6) = DateAdd("yyyy", 1, Lb_buscar.List(Lb_buscar.ListCount - 1, 4)) - Date
End If
End If
End If
Next
End Sub
1 Respuesta
Respuesta de Dante Amor
2
