How to clear duplicate values not delete the rows

Arinoum

Board Regular
Joined
Sep 28, 2016
Messages
64
Hi,
Is there a way to clear duplicate values without deleting the rows? I want the unique value to repeat only once and all below duplicates cleared from the cell not deleted. In the below example all information repeats but I only want it to repeat once for columns Name and Sales Person where originally this document repeated the name and Sales person down until a new number in the number column started.
Any help is greatly appreciated. Thanks!
NumberdateNameSales Person
1234/20/21Capital OneJohn
1234/20/21
1234/20/21
1244/19/21BOFAKelly
1244/19/21
1244/19/21
1244/19/21
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi,​
differents ways but as you forgot to indicate the range address …​
 
Upvote 0
Hi,​
differents ways but as you forgot to indicate the range address …​
C2 to D8. The original document repeats all information across the rows. I only want the info to repeat once. Thank you!

NumberdateNameSales Person
1234/20/21Capital OneJohn
1234/20/21Capital OneJohn
1234/20/21Capital OneJohn
1244/19/21BOFAKelly
1244/19/21BOFAKelly
1244/19/21BOFAKelly
1244/19/21BOFAKelly
 
Upvote 0
A demonstration as a beginner starter :​
VBA Code:
Sub Demo1()
    With [A1].CurrentRegion.Columns("C:D")
            V = .Value2
        For R& = .Rows.Count To 3 Step -1
            If V(R, 1) = V(R - 1, 1) Then V(R, 1) = Empty
            If V(R, 2) = V(R - 1, 2) Then V(R, 2) = Empty
        Next
           .Value2 = V
    End With
End Sub
 
Upvote 0
A demonstration as a beginner starter :​
VBA Code:
Sub Demo1()
    With [A1].CurrentRegion.Columns("C:D")
            V = .Value2
        For R& = .Rows.Count To 3 Step -1
            If V(R, 1) = V(R - 1, 1) Then V(R, 1) = Empty
            If V(R, 2) = V(R - 1, 2) Then V(R, 2) = Empty
        Next
           .Value2 = V
    End With
End Sub
It worked! Thank you so much!
 
Upvote 0
A demonstration as a beginner starter :​
VBA Code:
Sub Demo1()
    With [A1].CurrentRegion.Columns("C:D")
            V = .Value2
        For R& = .Rows.Count To 3 Step -1
            If V(R, 1) = V(R - 1, 1) Then V(R, 1) = Empty
            If V(R, 2) = V(R - 1, 2) Then V(R, 2) = Empty
        Next
           .Value2 = V
    End With
End Sub
Is there a way to edit this to only delete duplicate values once a new number is introduced in column A? In the below example I would like the duplicate values in column C and D to only repeat once there is a new number on column A. In this case only show the value in C2 and D2 and then again C5 and D5 since the number in column A changed. Is this possible?


NumberdateNameSales Person
1234/20/21Capital OneJohn
1234/20/21Capital OneJohn
1234/20/21Capital OneJohn
1244/19/21Capital OneJohn
1244/19/21Capital OneJohn
1244/19/21Capital OneJohn
1244/19/21Capital OneJohn
 
Upvote 0
Yes, my revamped demonstration :​
VBA Code:
Sub Demo1r()
    With [A1].CurrentRegion.Columns("C:D")
            V = .Value2
            W = .Item(-1).Value2
        For R& = .Rows.Count To 3 Step -1
            If W(R, 1) = W(R - 1, 1) Then
                If V(R, 1) = V(R - 1, 1) Then V(R, 1) = Empty
                If V(R, 2) = V(R - 1, 2) Then V(R, 2) = Empty
            End If
        Next
           .Value2 = V
    End With
End Sub
 
Upvote 0
Here is a way to write a macro that does not use any loops...
VBA Code:
Sub Demo2()
  Dim LR As Long
  LR = Cells(Rows.Count, "A").End(xlUp).Row
  Range("C2:D" & LR) = Evaluate("IF(A2:A" & LR & "<>A1:A" & LR - 1 & ",C2:D" & LR & ","""")")
End Sub
 
Upvote 0

Yes I badly revised my demonstration according to only the column A as key it needs a single If …​
 
Upvote 0
Here is a way to write a macro that does not use any loops...
VBA Code:
Sub Demo2()
  Dim LR As Long
  LR = Cells(Rows.Count, "A").End(xlUp).Row
  Range("C2:D" & LR) = Evaluate("IF(A2:A" & LR & "<>A1:A" & LR - 1 & ",C2:D" & LR & ","""")")
End Sub
Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top