Jump to content
Fórum Script Brasil
  • 0

Remover Duplicadas com VBA


Question

Boa tarde tudo bem? 

Preciso remover duplicadas que estão em mais de uma coluna, estava fazendo um teste com apenas duas. 

Usei o seguinte:

 

Sub excluirRepetidos()

Dim anterior As Long
Dim posterior As Long

For anterior = 2 To Sheets(1).UsedRange.Rows.Count - 1

For posterior = anterior + 1 To Sheets(1).UsedRange.Rows.Count

If Sheets(1).Cells(anterior, 1).Value = Sheets(1).Cells(posterior, 1).Valeu Then
If Sheets(1).Cells(anterior, 2).Value = Sheets(1).Cells(posterior, 2).Valeu Then

Sheets(1).Cells(posterior, 1).EntireRow.Delete

End If
End If

 Next posterior
 Next anterior
 
End Sub

 

Dessa forma gostaria que ele validasse nas duas colunas se tem algo repetido com a linha anterior e se positivo removesse a linha, porém, da erro na linha: If Sheets(1).Cells(anterior, 1).Value = Sheets(1).Cells(posterior, 1).Valeu Then

O que posso fazer?

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      148894
    • Total Posts
      644916
×
×
  • Create New...