VBA to clear duplicate dates in column but keep row

Tocix

New Member
Joined
Apr 17, 2016
Messages
24
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.

ABCD
110/15/2019lesson plansTBATBA
210/15/2019
homework
TBATBA
310/15/2019extra credit
TBATBA
4
510/16/2019TBATBATBA
610/16/2019TBATBATBA
10/17/2019TBATBATBA

<tbody>
</tbody>


Thanks
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
7,154
Office Version
2019
Platform
Windows
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.
 

Tocix

New Member
Joined
Apr 17, 2016
Messages
24
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.
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
7,154
Office Version
2019
Platform
Windows
The conditional formatting will carry over as well so the duplicates will be hidden in the copy.
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
42,246
Office Version
365
Platform
Windows
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
 

Tocix

New Member
Joined
Apr 17, 2016
Messages
24
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.
 

Forum statistics

Threads
1,082,135
Messages
5,363,344
Members
400,729
Latest member
Lisa McConachy

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top