Notifications
Clear all

Agrupar 3 Abas em uma ABA Só Chamada FINAL!!!

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

Pessoal,

Estou com um problemão tenho 3 abas, nestas abas a varias colunas x linhas com informação!

OBS : Nas 3 abas são exatamente o mesmo numero de COLUNAS! Já as linhas mudam!

1º Passo - Preciso que faça um RANGE(A:P) na ABA1 até a ultima LINHA X COLUNA valida, COPIE e cole na ABAFINAL!
2º Passo - Faça o RANGE(A:P) novamente, agora na ABA2 até a ultima LINHA X COLUNA valida, COPIE e cole na ABAFINAL, assim que encontrar a primeira linha valida!
3º Passo - Faça o RANGE(A:P) novamente, agora na ABA3 até a ultima LINHA X COLUNA valida, COPIE e cole na ABAFINAL, assim que encontrar a primeira linha valida!

No final deve ficar na ABAFINAL os valores um abaixo do outro de acordo com a sequencia de abas 1,2,3!

Obrigado e porfavor me ajudem |:

Link da XLS, com exemplo dos dados e Abas que citei!
http://www.4shared.com/file/dU3QDeIV/Ex ... cel_2.html

 
Postado : 16/07/2012 8:56 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

:D

 
Postado : 16/07/2012 8:57 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Sem VBA. Excel 2003.

A única coisa a definir é a ordem (aba ORDEM) que vc deseja.

O resto vem automático.

Me avise se funciona pois nao testei como deveria.

Abs,

 
Postado : 16/07/2012 10:25 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Bom dia!!

Veja o código do autor:Jerry Beaucaire
https://sites.google.com/a/madrocketsci ... to-1-sheet

Baixe o arquivo já adaptado
http://www.sendspace.com/file/qr4ny5

Option Explicit

Sub ConsolidarPlanilhas()
'Author:    Jerry Beaucaire
'Date:      6/26/2009
'Updated:   6/23/2010
'Merge all sheets in a workbook into one summary sheet (stacked)
'Data is sorted by a specific column name
Dim cs As Worksheet, ws As Worksheet
Dim LR As Long, NR As Long, sCol As Long
Dim sName As Boolean, SortStr As String
Application.ScreenUpdating = False

'From the headers in data sheets, enter the column title to sort by when finished
SortStr = "Nome"

'Add consolidation sheet if needed
If Not Evaluate("ISREF(PlanFinal!A1)") Then _
    Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "PlanFinal"

'Option to add sheet names to consolidation report
sName = MsgBox("Adicione o nome da folha de relatório de PlanFinal?", vbYesNo + vbQuestion) = vbYes

'Setup
Set cs = ActiveWorkbook.Sheets("PlanFinal")
cs.Cells.ClearContents
NR = 1

'Process each data sheet
    For Each ws In Worksheets
        If ws.Name <> cs.Name Then
            LR = ws.Range("A" & ws.Rows.Count).End(xlUp).Row
            'customize this section to copy what you need
            If NR = 1 Then
              'copy titles and data to start the consolidation, edit row as needed for source of titles
                ws.Range("A1", ws.Cells(1, Columns.Count).End(xlToLeft)).Copy
                If sName Then
                    cs.Range("B1").PasteSpecial xlPasteAll
                Else
                    cs.Range("A1").PasteSpecial xlPasteAll
                End If
                NR = 2
            End If
            
            ws.Range("A2:BB" & LR).Copy     'copy data, edit as needed for the start row

            If sName Then       'paste and add sheet names if required
                cs.Range("B" & NR).PasteSpecial xlPasteValuesAndNumberFormats
                cs.Range("A" & NR, cs.Range("B" & cs.Rows.Count).End(xlUp).Offset(0, -1)) = ws.Name
            Else
                cs.Range("A" & NR).PasteSpecial xlPasteValuesAndNumberFormats
            End If
            
            NR = cs.Range("A" & cs.Rows.Count).End(xlUp).Row + 1
        End If
    Next ws

'Sort
    LR = cs.Range("A" & cs.Rows.Count).End(xlUp).Row
    On Error Resume Next
    sCol = cs.Cells.Find(SortStr, After:=cs.Range("A1"), LookIn:=xlValues, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Column
    cs.Range("A1:BB" & LR).Sort Key1:=cs.Cells(2, sCol + (IIf(sName, 1, 0))), Order1:=xlAscending, _
        Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
        Orientation:=xlTopToBottom, DataOption1:=xlSortNormal

'Cleanup
    If sName Then cs.[A1] = "PlanFinal"
    cs.Rows(1).Font.Bold = True
    cs.Cells.Columns.AutoFit
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    cs.Activate
    Range("A1").Select
    Set cs = Nothing
End Sub

Att

 
Postado : 17/07/2012 6:15 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
Topic starter
 

Mandrix, acho que você não entendeu a IDEIA! Mais vlw a tentativa! Muito Obrigado!

E Alexandre, muito bom era isso mesmo que eu queria, apenas fiquei meio conturbado com o CÓDIGO pois a sintaxes ali são meio HARDS, pois não são de meu dia a dia! :P

muito obrigado! Me ajudou muito! muito obrigado mesmo

:D

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

Bom dia!!

Obrigado pelo retorno!

Se foi ultil favor clicar na mãozinha!!

Att

 
Postado : 18/07/2012 4:55 am