Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
#23761
Caros,

Gostaria de gerar uma plan3 que contivesse os dados de plan1 mais um dos dados de plan2. Exemplo abaixo.

Plan1 Plan2
A B C D A B C D
1 2 3 4 5 6 7 8

Plan3
A B C D
1 2 3 4
1 2 3 5
1 2 3 6
1 2 3 7
1 2 3 8
#23795
Boa tarde!!

O que é Plan1 e Pla2, são guias? ou arquivos?

Se for guias de um único arquivo, você deseja unir na terceira guia do mesmo arquivo?
Código: Selecionar todos
Sub AleVBA_4812()

Dim ws  As Worksheet, LR1 As Long, LR2 As Long
Application.ScreenUpdating = False
    For Each ws In ActiveWorkbook.Worksheets
        If ws.Name <> "Plan3" Then
            LR1 = Sheets("Plan3").Range("A" & Rows.Count).End(xlUp).Row + 1
            LR2 = ws.Range("D" & Rows.Count).End(xlUp).Row
            ws.Range("A1:D" & LR2).Copy Destination:=Sheets("Plan3").Range("A" & LR1)
        End If
    Next ws
Application.ScreenUpdating = True
End Sub

Att
#23799
alexandrevba escreveu:Boa tarde!!

O que é Plan1 e Pla2, são guias? ou arquivos?


Se for guias de um único arquivo, você deseja unir na terceira guia do mesmo arquivo?

Att
Olá Alexandre. Sim, são guias de um único arquivo, porém na terceira guia eu gostaria de unir todos números que estão na guia 1 acrescentando um número da guia 2 gerando assim as linhas. Eu estou colocando uma arquivo em anexo onde na guia3 eu deixo claro o resultado esperado. Acredito que seja algo muito parecido com esta sua codificação.

Grato desde já
Você não está autorizado a ver ou baixar esse anexo.
#23800
Boa tarde!!

Não muda nada além do nome da guia!
Código: Selecionar todos
Sub AleVBA_4812()

Dim ws  As Worksheet, LR1 As Long, LR2 As Long
Application.ScreenUpdating = False
    For Each ws In ActiveWorkbook.Worksheets
        If ws.Name <> "Sheet3" Then
            LR1 = Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Row + 1
            LR2 = ws.Range("D" & Rows.Count).End(xlUp).Row
            ws.Range("A1:D" & LR2).Copy Destination:=Sheets("Sheet3").Range("A" & LR1)
        End If
    Next ws
Application.ScreenUpdating = True
End Sub
Att
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord