I'm doing a macro that consists of deleting duplicate data from a column in excel, (keep the first data and delete the remaining data), the problem is that I have to execute the macro many times to perform the task completely, this is my code, to see if you can guide me.
Sub Principal()
Dim lngFila As Long
Dim strB As String
Dim strColumnaB As String
Dim valor1 As String
Dim valor2 As String
Dim contador As Integer
lngFila = 1
strB = "B"
strColumnaB = strB + CStr(lngFila)
Do
Range(strColumnaB).Select
valor1 = Range(strColumnaB).Value
lngFila = lngFila + 1
strColumnaB = strB + CStr(lngFila)
Range(strColumnaB).Select
valor2 = Range(strColumnaB).Value
If (valor1 = valor2) Then
Range(strColumnaB).EntireRow.Delete
End If
Loop Until Range(strColumnaB).Value = ""
End Sub