Cargar listbox vba Excel y filtrar solo los registros con datos.
-Tengo en Excel un frm_Salidas que al introducir un código en el campo me abre otro que le llamo frm_lote y me carga de este articulo todos los lotes que tengo, hasta ahí todo bien. Lo que pretendo es que en el evento actívate solo cargue los lotes que tengan existencia es decir mayor que 0.

Private Sub UserForm_Activate()
On Error GoTo Salir
Me.lista_Lote.Clear
'Aquí cargo datos de los tablas, de la tbl_existencias cargo la cantidad, ¿no se si está bien?
Items = Range("tbl_Entradas").CurrentRegion.Rows.Count
items = Range("tbl_Existencias").CurrentRegion.Rows.Count
For i = 2 To items
If LCase(Hoja3.Cells(i, 2).Value) Like LCase(frm_Salidas.ComboBox1.Value) Then
Me.lista_Lote.AddItem Hoja3.Cells(i, 2)
Me.lista_Lote.List(Me.lista_Lote.ListCount - 1, 1) = Hoja3.Cells(i, 3)
Me.lista_Lote.List(Me.lista_Lote.ListCount - 1, 2) = Hoja5.Cells(i, 5)
Me.lista_Lote.List(Me.lista_Lote.ListCount - 1, 3) = Hoja3.Cells(i, 17)
Me.lista_Lote.List(Me.lista_Lote.ListCount - 1, 4) = Hoja3.Cells(i, 18)
vLote = Hoja3.Cells(i, 17)
vCaducidad = Hoja3.Cells(i, 18)
End If
Next i
Exit Sub
Salir:
If Err <> 0 Then
MsgBox Err.Description, vbExclamation, "Control de Almacen"
End If
End Sub
1 respuesta
Respuesta
1
