VBA to clear duplicate dates in column but keep row

Tocix

New Member
Joined
Apr 17, 2016
Messages
48
Office Version
  1. 365
Good morning,

Please help me out with macros that would cleared out duplicate dates on column A but keep all rows. For example clear out the one I have it in red.

[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]10/15/2019[/TD]
[TD]lesson plans[/TD]
[TD]TBA[/TD]
[TD]TBA[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]10/15/2019
[/TD]
[TD]homework
[/TD]
[TD]TBA[/TD]
[TD]TBA[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]10/15/2019[/TD]
[TD]extra credit
[/TD]
[TD]TBA[/TD]
[TD]TBA[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]10/16/2019[/TD]
[TD]TBA[/TD]
[TD]TBA[/TD]
[TD]TBA[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]10/16/2019[/TD]
[TD]TBA[/TD]
[TD]TBA[/TD]
[TD]TBA[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]10/17/2019[/TD]
[TD]TBA[/TD]
[TD]TBA[/TD]
[TD]TBA[/TD]
[/TR]
</tbody>[/TABLE]


Thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try applying conditional formatting to the used part of column A. Use =A1=A2 as the rule, then set the font colour the same as the fill colour.

This will hide the date instead of removing them, which is more useful if you need to summarise your data by date at a later point.
 
Upvote 0
When I copied to another sheet the duplicate dates still carried over. I just want to clear it out completely that way my other sheet only have one date shown.
 
Upvote 0
The conditional formatting will carry over as well so the duplicates will be hidden in the copy.
 
Upvote 0
Try
Rich (BB code):
Sub Remove_Dupes()
  Dim r As Long
  
  For r = Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
    If Range("A" & r).Value = Range("A" & r - 1).Value Then Range("A" & r).ClearContents
  Next r
End Sub
 
Upvote 0
Try
Rich (BB code):
Sub Remove_Dupes()
  Dim r As Long
  
  For r = Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
    If Range("A" & r).Value = Range("A" & r - 1).Value Then Range("A" & r).ClearContents
  Next r
End Sub

Works perfectly! thank you very much for your help.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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