Página 1 de 1

Transpor dados das linhas duplicadas

Enviado: 26 Jul 2019 às 22:57
por JeffSchultz
Olá,

Precisava uma maneira de transpor dados onde a coluna A está duplicado e coluna C são dados exclusivos, gostaria de inserir os dados duplicados em novas colunas.

Re: Transpor dados das linhas duplicadas

Enviado: 27 Jul 2019 às 07:43
por eduardogrigull
Olá,
resolvi o seu problema com um Script em VBA, se eu entendi direito, claro.

Basta jogar num módulo
Código: Selecionar todos
Sub OrganizarLinhas()
Dim UltimaLinha As Integer

Plan4.Activate  'Alterar pra sua planilha

UltimaLinha = Range("A2").End(xlDown).Row


For i = 2 To UltimaLinha

    For j = 3 To UltimaLinha
        
        If i = j Then GoTo Proximo
        If Cells(i, 1).Value = Cells(j, 1).Value Then
            
            'Transferir
            If Cells(i, 4).Value = Empty Then
                Cells(i, 4).Value = Cells(j, 3).Value
            ElseIf Cells(i, 5).Value = Empty Then
                Cells(i, 5).Value = Cells(j, 3).Value
            Else
                Cells(i, 6).Value = Cells(j, 3).Value
            End If
            
            'Excluir linha antiga
            ActiveSheet.Rows(j & ":" & j).Delete Shift:=xlUp
            
            UltimaLinha = UltimaLinha - 1
        End If
Proximo:
    Next
Next
End Sub