Get Rid of the False Positive Results of the Code.
To Whom It May Concern,
I try to replace 5 cells of Row N to "Same As Above" when the values of these cells of Row N are same as those of Row N-1 respectively.
However, I always have problem with false positive results, i.e. they are not the same, but replaced anyway.
PHP Code:
Sub Test_Lease() ' ' Test_Lease Macro ' ' Proper all worksheet Dim ws As Object Dim LCell As Range Dim X As Long Dim Lr As Long X = ActiveSheet.UsedRange.Rows.Count Lr = Cells(Rows.Count, "A").End(xlUp).Row + 1
' Replace Duplicate Lease Production X = ActiveSheet.UsedRange.Rows.Count Y = 0 Range("T" & X, "X" & X).Select For n = 1 To X - 1 For Each cell In Selection If cell = cell.Offset(-1, 0) Then Y = Y + 1 End If If Y = 5 Then Selection.Value = "Same As Above" Y = 0 End If Next Selection.Offset(-1, 0).Select Next
Application.ScreenUpdating = True
End Sub
Please refer to the code & attachment.
The false positive will be on Row 126 & Column T-X after you run the code. Please help.
Bookmarks