Error en código de búsqueda, no me refleja datos en el listbox
Estoy modificando el código de la búsqueda de una base de datos me los mande a labels y a un listbox, se cargan los datos en los label pero en el listbox NO. :C soy nuevo usando el listbox y estoy complicado mucho aquí dejo el código para ver si me ayudan a ver el error
Sub busca2()
'Por.Dante Amor
Application.ScreenUpdating = False
Set h1 = PRUEBAS
Set h2 = Sheets("history")
'folio = h1.Range("L3").Value
folio = h1.TextBox1.Value
If folio = "" Then
MsgBox "Escribe algo en el textbox1"
Exit Sub
End If
'
j = 21
Set r = h2.Columns("A") 'rango de búsqueda
Set b = r.Find(folio, lookat:=xlWhole) 'busca folio
If Not b Is Nothing Then
celda = b.Address
Do
fila = h1.ListBox1.ListIndex
'Datos del cliente
H1. Label1.Caption = h2. Cells(b.Row, "A") ' cliente
H1. Label2.Caption = h2. Cells(b.Row, "B") '
h1.Label3.Caption = h2.Cells(b.Row, "C")
'detalle de productos
H1. ListBox1. List(h1. ListBox1.ListCount - 1, 1) = h2. Cells(b.Row, "D")
' ListBox1.List(fila, 1) = h2. Cells(b.Row, "E")
' ListBox1.List(fila, 2) = h2. Cells(b.Row, "F")
' ListBox1.List(fila, 3) = h2. Cells(b.Row, "G")
j = j + 1
Set b = r.FindNext(b)
Loop While Not b Is Nothing And b.Address <> celda
Else
MsgBox "El folio no existe"
End If
Application.ScreenUpdating = True
End Subaqui las imagenes,


1 Respuesta
Respuesta de Dante Amor
1