Im completely novice on VBA but i found no solution in google so far. i find 2 seperate code but when combining the solution didnt find out
I have a issue of deleting duplicate row with condition
column b column z
1 22/1/2019
2 22/1/2019
1 23/1/201
2 23/1/2019
outcome
column b column z
1 23/1/2019
2 23/1/2019
My code ( having problem when nested do while with for )
Sub Macro1()
Dim RowsToDelete As Range, innerRow As Long
Set TheRng = Intersect(ActiveSheet.UsedRange, ActiveSheet.Range("B:Z"))
xx = TheRng.Value
innerRow = 1
For i = UBound(xx) To 2 Step -1
Do While ActiveSheet.Range("b" & Row) <> ""
If ActiveSheet.Range("b" & Row) = ActiveSheet.Range("b" & innerRow) Then
For j = i - 1 To 1 Step -1
If ActiveSheet.Range("Z" & Row) < ActiveSheet.Range("Z" & innerRow) Then
Set RowsToDelete = Union(IIf(RowsToDelete Is Nothing, TheRng.Cells(i, 1), RowsToDelete), TheRng.Cells(i, 1))
Exit For
End If
Next j
Loop
RowsToDelete.EntireRow.Select 'Delete
End Sub