I have a set of data that can have duplicates in column P. Where a duplicate exists, I want to clear the contents of P:S. The underlying code does that, but it doesn't clear the contents for every duplicate value. I'm not sure how to accomplish the desired result.
VBA Code:
Sub test()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim m As Workbook
Dim mS As Worksheet
Dim mSLR As Long
Dim c As Range
Set m = ThisWorkbook
Set mS = m.Sheets("Sheet1")
mSLR = mS.Range("A" & Rows.Count).End(xlUp).Row
For Each c In mS.Range("P2:P" & mSLR)
With c
If .Value = c.Offset(-1, 0).Value Then .Resize(, 4).ClearContents
End With
Next c
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub