Notifications
Clear all

Agrupar dados da planilha usando VBA como?

7 Posts
2 Usuários
0 Reactions
1,407 Visualizações
(@jason)
Posts: 0
New Member
Topic starter
 

Bom dia

Pessoal

Aonde trabalho o pessoal tem dificuldades com excel, estou tentando deixar o mais simples possível a planilha, a aba Pedidos é como é feito a exportação do sistema aonde trabalho, eu preciso que ao clicar no botão gerar relatório ele fique como o da aba Agrupar e que seja feito a soma, para que seja enviado a cliente.
Essa planilha será a base, sempre os dados serão alterados.

Se alguém puder me ajudar agradeço.

Atenciosamente,
Elizeu.

 
Postado : 29/05/2015 4:11 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Bom dia!!

Se alguém puder me ajudar agradeço.

Sem seu arquivo modelo, ao menos para mim é impossível!!

Att

 
Postado : 29/05/2015 5:21 am
(@jason)
Posts: 0
New Member
Topic starter
 

Desculpa.

Arquivo anexo.

 
Postado : 29/05/2015 5:56 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Boa tarde!!

Tente

Sub AleVBA_16024()
    Dim lastrow As Long
    Application.ScreenUpdating = False
        With Worksheets("Agrupar")
            lastrow = .Cells(Rows.Count, "B").End(xlUp).Row
            .AutoFilterMode = False
            .Range("O1") = "AleVBA"
            .Range("O2:O" & lastrow).Formula = "=COUNTIF($F$2:F2,F2)>1"
            .Range("O1:O" & lastrow).AutoFilter field:=1, Criteria1:="VERDADEIRO"
            .Range("A2:E" & lastrow).Offset(1, 0).SpecialCells(xlCellTypeVisible).ClearContents
            .AutoFilterMode = False
            .Range("O1:O" & lastrow).ClearContents
        End With
    Application.ScreenUpdating = True
End Sub

Att

 
Postado : 29/05/2015 10:27 am
(@jason)
Posts: 0
New Member
Topic starter
 

Boa tarde!!

Tente

Sub AleVBA_16024()
    Dim lastrow As Long
    Application.ScreenUpdating = False
        With Worksheets("Agrupar")
            lastrow = .Cells(Rows.Count, "B").End(xlUp).Row
            .AutoFilterMode = False
            .Range("O1") = "AleVBA"
            .Range("O2:O" & lastrow).Formula = "=COUNTIF($F$2:F2,F2)>1"
            .Range("O1:O" & lastrow).AutoFilter field:=1, Criteria1:="VERDADEIRO"
            .Range("A2:E" & lastrow).Offset(1, 0).SpecialCells(xlCellTypeVisible).ClearContents
            .AutoFilterMode = False
            .Range("O1:O" & lastrow).ClearContents
        End With
    Application.ScreenUpdating = True
End Sub

Att

Teria como ao criar um botão para ele exporta os dados para outra aba e excluir as colunas Cod. de Separação, Status e no final da coluna Peso e Volume e efetuar a soma.

Desde já agradeço a ajuda.

Atenciosamente,
Elizeu.

 
Postado : 29/05/2015 11:47 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Boa tarde!!

Não encontrei a coluna Cod. de Separação!

Como deve ser essa soma?

Option Explicit
Sub AleVBA_16024V2()
    Dim sh As Worksheet
    Dim ws As Worksheet
    Dim lastrow As Long
    
    Set sh = Worksheets("Pedidos")
    Set ws = Worksheets("Agrupar")
    sh.Activate
    Application.ScreenUpdating = False
        ws.Cells.Clear
        sh.Range("A1", Range("N" & Rows.Count).End(xlUp)).Copy ws.Range("A65536").End(xlUp)(2)
        With ws
            lastrow = .Cells(Rows.Count, "B").End(xlUp).Row
            .Rows(1).EntireRow.Delete
            .AutoFilterMode = False
            .Range("O1") = "AleVBA"
            .Range("O2:O" & lastrow).Formula = "=COUNTIF($F$2:F2,F2)>1"
            .Range("O1:O" & lastrow).AutoFilter field:=1, Criteria1:="VERDADEIRO"
            .Range("A2:E" & lastrow).Offset(1, 0).SpecialCells(xlCellTypeVisible).ClearContents
            .AutoFilterMode = False
            .Range("O1:O" & lastrow).ClearContents
            .Columns(8).EntireColumn.Delete 'além da coluna Status não  Cod. de Separação
            .Range("H" & lastrow).Formula = "=SUBTOTAL(9,H2:H" & lastrow - 1 & ")"
            .Range("I" & lastrow).Formula = "=SUBTOTAL(9,I2:I" & lastrow - 1 & ")"
        End With
    Application.ScreenUpdating = True
End Sub

Att

 
Postado : 29/05/2015 2:33 pm
(@jason)
Posts: 0
New Member
Topic starter
 

Era isso mesmo o que eu precisava, muito obrigado.

 
Postado : 29/05/2015 7:24 pm