¿Cómo mostrar información en un listbox de una hoja por con filtro de una hoja y?

Para Dante Amor

Buenas tardes! Le cuento que tengo un requisito que no puedo solucionar!

Necesito mostrar en un listbox facturas asociadas a un proyecto,

Pero en una hoja tengo los proyectos con las ordenes de compra asociadas,

Y en otra hoja están las facturas con odc asociadas (una orden de compra puede tener más de una factura)

en la hoja "proyectos_excel" tengo las odc asociadas a un proyecto

Y la hoja de las facturas(no pude subir la otra imagen) pero esta asociada a una orden de compra, el problema es que no se como hacer ese filtro para que muestre las facturas asociadas a un proyecto .

1 Respuesta

Respuesta
1

H o l a:

Envíame tu archivo con el userform actualizado, la hoja factura y me explicas con un ejemplo qué busco y qué datos quieres de resultado.

Te anexo el código

Sub CargarFacturas()
    'CARGAR Facturas A LISTBOX3
    ListBox3. Clear
    Set h1 = Sheets("Temp")
    Set h2 = Sheets("libro-mayor")
    h1.Cells.Clear
    j = 1
    For i = 0 To ListBox2.ListCount - 1
        If IsNumeric(ListBox2.List(i, 0)) Then odc = Val(ListBox2.List(i, 0)) Else odc = ListBox2.List(i, 0)
        Set b = h1.Columns("A").Find(odc, lookat:=xlWhole)
        If b Is Nothing Then
            h1.Cells(j, "A") = odc
            j = j + 1
        End If
    Next
    '
    For i = 1 To h1.Range("A" & Rows.Count).End(xlUp).Row
        Set r = h2.Columns("G") 'columna de odc en libro_mayor
        Set b = r.Find(h1.Cells(i, "A"), lookat:=xlWhole)
        If Not b Is Nothing Then
            celda = b.Address
            Do
                ListBox3. AddItem h1. Cells(i, "A") 'odc
                ListBox3. List(ListBox3.ListCount - 1, 1) = h2. Cells(b. Row, "H") 'Factura
                ListBox3. List(ListBox3.ListCount - 1, 2) = h2. Cells(b. Row, "E") 'Monto
                ListBox3. List(ListBox3.ListCount - 1, 3) = h2. Cells(b. Row, "I") 'Proveedor
                ListBox3. List(ListBox3.ListCount - 1, 4) = h2. Cells(b. Row, "D") 'Trabajo
                ListBox3. List(ListBox3.ListCount - 1, 5) = h2. Cells(b. Row, "L") 'Estado
                Set b = r.FindNext(b)
            Loop While Not b Is Nothing And b.Address <> celda
        End If
    Next
End Sub
'
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    op_editar.Value = False
    txtodc.Text = ""
    txtmontoodc = ""
    txtodc.Enabled = False
    txtmontoodc.Enabled = False
    Dim Cuenta As Integer
    Dim Numero As Integer
    Dim j As Integer
    Dim i As Integer
    '
    Cuenta = Me.ListBox1.ListCount
    '
    'Validamos que haya un elemento seleccionado.
    For j = 0 To Cuenta - 1
        If Me.ListBox1.Selected(j) = True Then
            Numero = Numero + 1
        End If
    Next j
    '
    'La hoja seleccionada se pasará al ListBox de hojas visibles.
    For i = 0 To Cuenta - 1
        If Me.ListBox1.Selected(i) = True Then
            'MsgBox Me.ListBox1.List(i, 1), vbInformation, "EXCELeINFO"
            txtproyecto.Text = Me.ListBox1.List(i, 1)
            txtmarca.Text = Me.ListBox1.List(i, 2)
            txttotalproyecto.Text = Me.ListBox1.List(i, 3)
            Hoja1.Range("J1").Value = Me.ListBox1.List(i, 0)
        End If
    Next i
    'CARGAR ODC A LISTBOX2
        Call CargarOdc
    '
    'CARGAR FACTURAS
        Call CargarFacturas
End Sub
'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas