ListBox com filtro interno

eferreiralima

19-01-2018 16:29:55

Prezados, preciso da ajuda de vocês com seguinte situação:

Tenho uma planilha com os seguintes dados:

Nº DOCUMENTO NOME EMPRESA PLACA DATA ENTRADA HORA ENTRADA DATA SAIDA HORA SAIDA
99999999-9 FULANO A ABC AAA-1111 19/01/2018 8:00 19/01/2018 10:00
88888888-8 FULANO B EF AAA-2222 19/01/2018 9:00
77777777-7 FULANO C GHI AAA-3333 19/01/2018 9:50 9/01/2018 12:00
66666666-6 FULANO D KL AAA-4444 19/01/2018 10:01
55555555-5 FULANO E MNO AAA-5555 19/01/2018 10:45

Preciso fazer uma ListBox que mostre somente os dados em que a coluna "DATA SAIDA" ou "HORA SAIDA" não estejam preenchidas.

Basole

19-01-2018 23:05:18

Veja este exemplo:
Altere os nomes dos objetos de acordo com a sua planilha.

Código: Selecionar todos

    Dim rng As Range
    Dim Lr  As Long
    Dim c   As Range
    Dim i   As Integer
    
    With ActiveSheet
        Lr = .Cells(Rows.Count, 1).End(xlUp).Row
        
        Set rng = .Range("A2:A" & Lr)
        
        With Me.ListBox1
            .ColumnCount = 8
            .ColumnWidths = "60 pt;120 pt;95 pt;60 pt;70 pt;70 pt;70 pt;70 pt"
            
            For Each c In rng
                
                If Not c.Offset(, 6).Value2 = Empty Or _
                    Not c.Offset(, 7).Value2 = Empty Then
                    
                    .AddItem
                    .List(i, 0) = c.Value2
                    .List(i, 1) = c.Offset(, 1).Value2
                    .List(i, 2) = c.Offset(, 2).Value2
                    .List(i, 3) = c.Offset(, 3).Value2
                    .List(i, 4) = VBA.Format(c.Offset(, 4).Value2, "dd/mm/yyyy")
                    .List(i, 5) = VBA.Format(c.Offset(, 5).Value2, "hh:mm:ss")
                    .List(i, 6) = VBA.Format(c.Offset(, 6).Value2, "dd/mm/yyyy")
                    .List(i, 7) = VBA.Format(c.Offset(, 7).Value2, "hh:mm:ss")
                    i = i + 1
                    
                End If
            Next c
        End With
        
    End With
    

eferreiralima

22-01-2018 09:54:22

Grande Basole, era exatamente o que eu queria.

muito grato pela sua colaboração.