Notifications
Clear all

Filtrar dados em outra planilha

3 Posts
3 Usuários
0 Reactions
722 Visualizações
(@tbr-felic)
Posts: 1
New Member
Topic starter
 

Boa tarde! Estou tentando usar essa macro para filtrar os dados em outra planilha, mas quando executo, trava o excel, e demorar muito para executar,
estou procurando alguma que faça esse mesmo trabalho, e tambem tenha atualização em cascata. Sub relatorio()

Plan4.Range("A2:k3000").ClearContents

ultimaLinha = Plan1.Cells(Rows.Count, "a").End(xlUp).Row

lin = 2

For i = 2 To ultimaLinha

If Plan1.Cells(i, 10) <> "MSEN ORDA" Then

Plan4.Cells(lin, 1) = Plan1.Cells(i, 1)
Plan4.Cells(lin, 2) = Plan1.Cells(i, 2)
Plan4.Cells(lin, 3) = Plan1.Cells(i, 3)
Plan4.Cells(lin, 4) = Plan1.Cells(i, 4)
Plan4.Cells(lin, 5) = Plan1.Cells(i, 5)
Plan4.Cells(lin, 6) = Plan1.Cells(i, 6)
Plan4.Cells(lin, 7) = Plan1.Cells(i, 7)
Plan4.Cells(lin, 8) = Plan1.Cells(i, 8)
Plan4.Cells(lin, 9) = Plan1.Cells(i, 9)
Plan4.Cells(lin, 10) = Plan1.Cells(i, 10)
Plan4.Cells(lin, 11) = Plan1.Cells(i, 11)
lin = lin + 1

End If

Next

End Sub

 
Postado : 05/11/2015 9:38 am
(@mprudencio)
Posts: 2749
Famed Member
 

Tente adaptar esse


Sub Filtro()

Dim WRV     As Workbook
Dim WVD     As Worksheet
Dim WUV     As Worksheet
Dim Visita  As Date

Application.ScreenUpdating = False
        Set WRV = Workbooks("Relatorio de Visitas")
        Set WVD = Sheets("Visitas do Dia")
        Set WUV = Sheets("Ultima Visita")
        
            WVD.Select
   Visita = WVD.Range("C5").Value
            WVD.Range("A8").Select
    Intersect(Selection.EntireRow, _
             Range("A:F")).Select
            WVD.Range(Selection, _
                Selection.End(xlDown)).Select
                Selection.ClearContents
            WVD.Range("A8").Select
            WUV.Select
            WUV.Range("K6").Select
                      
        Do While ActiveCell <> ""
            
            If ActiveCell = Visita Then
            
            Intersect(Selection.EntireRow, _
               Range("C:H")).Select
               Selection.Copy
                 WVD.Select
                 WVD.Range("A1048576").End(xlUp).Select
                ActiveCell.Offset(1, 0).Select
                
                Selection.PasteSpecial _
                Paste:=xlPasteValues, _
                   Operation:=xlNone, _
                   SkipBlanks:=False, _
                    Transpose:=False
                                                      
            Application.CutCopyMode = False
                     
           WUV.Select
           ActiveCell.Offset(1, 8).Select

            Else

            ActiveCell.Offset(1, 0).Select

            End If

        Loop
        
    WUV.Range("A1").Select
    WVD.Select
  
    WVD.Range("A8").Select
    
 

MsgBox "Relatorio de Visitas Gerado com Sucesso!", vbOKOnly, "Relatório de Vendas..."

WRV.Save

Application.ScreenUpdating = True

End Sub




Se nao conseguir poste o arquivo.

Marcelo Prudencio
Microsoft Excel Brasil no Facebook

"Começar já é a metade do caminho."
Autor Desconhecido

Simplifica que simples fica.
Nicole Tomazella.

"O Simples é Sempre Melhor Que o Complicado"
Jorge Paulo Lemann.

 
Postado : 05/11/2015 6:45 pm
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

tbr, se a intensão é "FILTRAR PARA OUTRA ABA", porque não utiliza o recurso de filtragem ?
Veja dois tópicos com exemplos e veja se ajuda, se pesquisar no forum pelos termo "filtro outra aba" encontrara vários tópicos sobre o assunto.

Filtro em outra aba !
viewtopic.php?f=22&t=2785

Filtro Avançado COLUNAS ESPECÍFICAS
viewtopic.php?f=10&t=3681

Se ajudar e não conseguir implementar, anexe um modelo reduzido e compactado (zip, Rar) conforme as regras do forum que procuraremos auxiliar.

[]s

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 05/11/2015 10:03 pm