Filtro Avançado
Enviado: Seg Mar 17, 2014 5:04 pm
Olá Pessoal ...
Recentemente o JoséA postou o código abaixo para filtrar meses. Há tempos eu uso ele nos meus trabalhos e me é muito útil. É possível adapta-lo para filtrar lançamentos duplicados para edição? Nas pesquisas no fórum só encontrei códigos que filtram a partir da 2ª Repetição. Eis o código:
Sub FiltroAvançado()
Application.EnableEvents = False
Dim lastRow As Long
Dim lastResultRow As Long
Dim X As Long
' Verifica qual a ultima célula preenchida
lastRow = Plan1.Cells(Rows.Count, 1).End(xlUp).Row
' Apaga valores anteriores
Plan2.Range("A2:AE65536").ClearContents
lastResultRow = 2 'linha resultado
' Ciclo em todas as linhas
For X = 7 To lastRow '1 Linha dados pequisa
' verifica se o valor é igual ao da pesquisa
If Month(CDate(Plan1.Cells(X, 4).Value)) = Plan1.Range("D3").Value Then '4coluna pequisa
' Copia os valores
Plan2.Cells(lastResultRow, 1).Value = Plan1.Cells(X, 1).Value
Plan2.Cells(lastResultRow, 2).Value = Plan1.Cells(X, 2).Value
Plan2.Cells(lastResultRow, 3).Value = Plan1.Cells(X, 3).Value
Plan2.Cells(lastResultRow, 4).Value = Plan1.Cells(X, 4).Value
Plan2.Cells(lastResultRow, 5).Value = Format(Plan1.Cells(X, 5).Value, "#,##0.000")
lastResultRow = lastResultRow + 1
End If
Next
Application.EnableEvents = True
Plan2.Select
If Plan2.[A2].Value = "" Then
MsgBox "Não temos vencimentos para o Mês pesquisado..."
End If
End Sub
. . . ou outras sugestões.
Abs
Beto Cunha
Recentemente o JoséA postou o código abaixo para filtrar meses. Há tempos eu uso ele nos meus trabalhos e me é muito útil. É possível adapta-lo para filtrar lançamentos duplicados para edição? Nas pesquisas no fórum só encontrei códigos que filtram a partir da 2ª Repetição. Eis o código:
Sub FiltroAvançado()
Application.EnableEvents = False
Dim lastRow As Long
Dim lastResultRow As Long
Dim X As Long
' Verifica qual a ultima célula preenchida
lastRow = Plan1.Cells(Rows.Count, 1).End(xlUp).Row
' Apaga valores anteriores
Plan2.Range("A2:AE65536").ClearContents
lastResultRow = 2 'linha resultado
' Ciclo em todas as linhas
For X = 7 To lastRow '1 Linha dados pequisa
' verifica se o valor é igual ao da pesquisa
If Month(CDate(Plan1.Cells(X, 4).Value)) = Plan1.Range("D3").Value Then '4coluna pequisa
' Copia os valores
Plan2.Cells(lastResultRow, 1).Value = Plan1.Cells(X, 1).Value
Plan2.Cells(lastResultRow, 2).Value = Plan1.Cells(X, 2).Value
Plan2.Cells(lastResultRow, 3).Value = Plan1.Cells(X, 3).Value
Plan2.Cells(lastResultRow, 4).Value = Plan1.Cells(X, 4).Value
Plan2.Cells(lastResultRow, 5).Value = Format(Plan1.Cells(X, 5).Value, "#,##0.000")
lastResultRow = lastResultRow + 1
End If
Next
Application.EnableEvents = True
Plan2.Select
If Plan2.[A2].Value = "" Then
MsgBox "Não temos vencimentos para o Mês pesquisado..."
End If
End Sub
. . . ou outras sugestões.
Abs
Beto Cunha