Como mostrar el ultimo valor de una columna
Hola Dan.. ¿tengo una duda en el código como lo hago para que me muestre el ultimo valor de la columna V según el código buscado en el textbox? Ya le he dado muchas vueltas a mi tema y se me ocurrió agregar dos columnas con datos columna U y V

Si te fijas me muestra el dato codigo bien en la columna 1 del listbox que seria el ultimo .. Pero en la segunda columna del listbox me muestra los primeros que encuentra de arriba hacia abajo y eso esta mal .. Debe mostrar el ultimo dato de la columna V según el código a buscar en el textbox
Private Sub txtbuscar_Change()
Application.ScreenUpdating = False
Lb_buscar.Clear
Lb_buscar.ColumnCount = 8
Lb_buscar.ColumnWidths = "60;100;90;110;120;130;100"
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, "P").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, "P").Value
' Lb_buscar.List(Lb_buscar.ListCount - 1, 2) = Hoja3.Cells(i, "V").Value
'''''''''''''''''
' Lb_buscar.List(Lb_buscar.ListCount - 1, 4) = Format(Hoja3.Cells(i, "R").Value, "short date")
' Lb_buscar.List(Lb_buscar.ListCount - 1, 5) = Hoja3.Cells(i, "Q").Value
' Lb_buscar.List(Lb_buscar.ListCount - 1, 6) = 365 + Hoja3.Cells(i, "Q").Value
' Lb_buscar.List(Lb_buscar.ListCount - 1, 7) = (365 + Hoja3.Cells(i, "Q").Value) - Date
End If
End If
Next
End Sub
1 Respuesta
Respuesta de Programar Excel
1