Notifications
Clear all

Busca referencia

3 Posts
1 Usuários
0 Reactions
555 Visualizações
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Dae pessoal, to precisando de uma ajuda aqui.

Tenho uma planilha com diversos dados que utilizo como banco, preciso filtrar dentro deste banco algumas colunas e transporta-las para outra planilha podendo ser dentro do mesmo documento.
Dentro deste banco tenho as Siglas Distritais
que estão na coluna A da planilha DADOS e são as referências de cada planilha que preciso alimentar.
Esquema:

Preciso alimentar as linhas da planilha DSMCTA com os dados das linhas correspondentes as colunas que existem na planilha.

Este banco é alimentado semanalmente.

Desculpem se não fui muito claro mas se puderem me ajudar qual coisa perguntem.

Em anexo segue planilha, e valeu pela ajuda :D :?:

 
Postado : 08/02/2012 8:13 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Boa tarde chaulin

Fiz o que vc pediu, filtrei os dados para a planilha DSMCTA, usando como critério a Sigla Distrital da Coluna A.
Diminuiu uma coluna de dados porque vc repetiu a coluna "Motivo Manutenção" Pode verificar que nas outras planilhas tem a dupla coluna.
Baixe a planilha e veja se é isto que vc precisa:

Se a resposta foi útil, faça a gentileza de clicar na mãozinha que fica ao lado da ferramenta Citar.

Dê retorno;

Abraço.

 
Postado : 09/02/2012 11:01 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Boa noite!!!

Tem um opção...utilizando VBA.

Faça uma adaptação.

Sub macroAle()
Application.ScreenUpdating = False
Dim AllCells As Range
Dim cell As Range, Rng As Range
Dim NoDupes As New Collection
Dim lrow As Long
Dim Myval As Integer
lrow = Sheets("Base").Range("C65536").End(xlUp).Row
Set AllCells = Sheets("Base").Range("C2:C" & lrow)
For Each cell In AllCells
    On Error Resume Next
    NoDupes.Add cell.Value, CStr(cell.Value)

    Next cell
    On Error GoTo 0
    For Each Item In NoDupes
    Union(Range("B:B"), Range("D:D")).EntireColumn.Hidden = True
    Range("A1:I1").Select
        Selection.AutoFilter
        With Selection
            .AutoFilter Field:=3, Criteria1:=Item '' this set the filtered data for the value
        End With
            Set Rng = ActiveSheet.AutoFilter.Range
            '' make sure you have more than 1 row to copy ''
            Myval = Range("C2:C" & lrow).SpecialCells(xlCellTypeVisible).Count
            If Myval <> "1" Then
                Rlrow = Sheets(Item).Range("A65536").End(xlUp).Row + 1
                    Rng.Offset(1, 0).Resize(Rng.Rows.Count - 1).Copy
                        Sheets(Item).Cells(Rlrow, 1).PasteSpecial xlValue
                    Application.CutCopyMode = xlCopy
            End If
    Next Item
    Selection.AutoFilter
    Union(Range("B:B"), Range("D:D")).EntireColumn.Hidden = False
End Sub

Sub Macro1()
Dim HowManyVisRows As Long
Dim VisRng As Range
'apply the filter someway
Dim iCtr As Long
With Worksheets("Base").AutoFilter.Range
'subtract one for the header.
HowManyVisRows _
= .Columns(1).Cells.SpecialCells(xlCellTypeVisible).Cells.Count - 1

If HowManyVisRows >= 2 Then
'avoid the header and come down one row
'and only look at one the first column
    Set VisRng = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
    .Cells.SpecialCells(xlCellTypeVisible)
    'VisRng.Offset(1, 0).Select
    'With ActiveCell
        Range(Cells(VisRng.Offset(0, 0).Row, 1), Cells(Range("D65536").End(xlUp).Row, 9)).Copy 'EntireRow.Delete
        'VisRng.Offset(1, 0).Resize(VisRng.Rows.Count - 1).Copy
        Sheets("Product1").Cells(2, 1).PasteSpecial xlValue
                    Application.CutCopyMode = xlCopy
   'End With
    
End If
End With
End Sub
 
Postado : 09/02/2012 7:11 pm