Anonymous
23-04-2012 20:15:38
Boa tarde
estou a procura de um filtro no formato que o Tomás colocou aqui (cadastro com Listview) que tenha opção filtra período entre datas e placa.
O que eu preciso na verdade é ver entre duas datas onde o veículo xxx-0000 foi. Este meu relatório tem muitas linhas e a cada dia acrescento mais.
Preciso de ajuda.
Coloco abaixo o filtro que eu tenho e posso adaptar para ser o filtro da placa. Mas além disto preciso criar dois outros parâmetros ou seja, no txtdataini quero colocar a data inicial e na txtdatafinal colocar a data final e ativar o filtro através de um btnatualizar. Quem consegue me ajudar?
Private Sub TextBoxFiltro_Change()
Dim strObjetoBuscar As String
Dim lngResultado As Long
Dim lngColumna As Long, lngFila As Long
Dim X As Integer, n As Integer
Dim col
coluna = Me.ComboBoxCampos.ListIndex + 1
ListView1.ListItems.Clear
strObjetoBuscar = TextBoxFiltro.Value
If strObjetoBuscar = "" Then GoTo 99
strObjetoBuscar = LCase(strObjetoBuscar)
For a = 2 To Plan4.Cells(Plan4.Cells.Rows.Count, "a").End(xlUp).Row
lngResultado = InStr(1, Plan4.Cells(a, coluna), strObjetoBuscar, vbTextCompare)
If lngResultado > 0 Then
Set li = ListView1.ListItems.Add(Text:=Format(Plan4.Range("A" & a).Value, "00"))
li.ListSubItems.Add Text:=Plan4.Range("B" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("C" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("D" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("E" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("F" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("G" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("H" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("I" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("J" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("K" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("L" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("m" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("n" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("o" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("P" & a).Value
End If
Next a
99:
End Sub
estou a procura de um filtro no formato que o Tomás colocou aqui (cadastro com Listview) que tenha opção filtra período entre datas e placa.
O que eu preciso na verdade é ver entre duas datas onde o veículo xxx-0000 foi. Este meu relatório tem muitas linhas e a cada dia acrescento mais.
Preciso de ajuda.
Coloco abaixo o filtro que eu tenho e posso adaptar para ser o filtro da placa. Mas além disto preciso criar dois outros parâmetros ou seja, no txtdataini quero colocar a data inicial e na txtdatafinal colocar a data final e ativar o filtro através de um btnatualizar. Quem consegue me ajudar?
Private Sub TextBoxFiltro_Change()
Dim strObjetoBuscar As String
Dim lngResultado As Long
Dim lngColumna As Long, lngFila As Long
Dim X As Integer, n As Integer
Dim col
coluna = Me.ComboBoxCampos.ListIndex + 1
ListView1.ListItems.Clear
strObjetoBuscar = TextBoxFiltro.Value
If strObjetoBuscar = "" Then GoTo 99
strObjetoBuscar = LCase(strObjetoBuscar)
For a = 2 To Plan4.Cells(Plan4.Cells.Rows.Count, "a").End(xlUp).Row
lngResultado = InStr(1, Plan4.Cells(a, coluna), strObjetoBuscar, vbTextCompare)
If lngResultado > 0 Then
Set li = ListView1.ListItems.Add(Text:=Format(Plan4.Range("A" & a).Value, "00"))
li.ListSubItems.Add Text:=Plan4.Range("B" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("C" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("D" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("E" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("F" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("G" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("H" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("I" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("J" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("K" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("L" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("m" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("n" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("o" & a).Value
li.ListSubItems.Add Text:=Plan4.Range("P" & a).Value
End If
Next a
99:
End Sub