how to delete repeating dates

mzalikhan

Board Regular
Joined
May 16, 2011
Messages
62
Hi all

I have got a spreadsheet with some repeating dates. for example, 1/1/2001 13:00 AM and 1/1/2001 15:00 AM.

What i want is to keep only one date data (either one).

Any idea how to do that?

Peace
Muhammad Zeeshan
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You could create a helper column with this formula:

=DATE(YEAR(B1),MONTH(B1),DAY(B1))

This will convert the dates to just a date and remove the time.
 
Upvote 0
This code will build a Helper Column that is then used to Delete Duplicates Dates while ignoring Times:
Code:
Sub DeleteDupeDates()
Dim Rng As Range, i As Long
Application.ScreenUpdating = False
    LR = Cells(Rows.Count, 1).End(xlUp).Row
    LC = Cells(1, Columns.Count).End(xlToLeft).Column + 1
    'Range(Cells(1, LC), Cells(LR, LC)).Select
    Range(Cells(1, LC), Cells(LR, LC)).Formula = "=INT(A1)"
    Range(Cells(1, LC), Cells(LR, LC)).NumberFormat = "mm/dd/yy;@"

Set Rng = Range(Cells(1, LC), Cells(LR, LC))
    'Cycle through helper column and Delete Duplicates
    For i = Rng.Rows.Count To 1 Step -1
      If Application.WorksheetFunction.CountIf(Rng, Cells(i, LC)) > 1 Then _
        Rows(i).EntireRow.Delete
    Next i
    'Clear Helper Column of formulae
    Range(Cells(1, LC), Cells(LR, LC)).ClearContents
Application.ScreenUpdating = True
End Sub
The Helper Column is then cleared of data at the end of the code.
 
Upvote 0
I have got a spreadsheet with some repeating dates. for example, 1/1/2001 13:00 AM and 1/1/2001 15:00 AM.
They are interesting times. What does 15:00 AM mean? Usually a time of 15:00 would be 3:00 PM.



=DATE(YEAR(B1),MONTH(B1),DAY(B1))

This will convert the dates to just a date and remove the time.
FYI: If B1 indeed does contain a real date/time, a simpler way to extract just the date is
=INT(B1)
 
Upvote 0
So, have you got a successful solution?

What version of Excel are you using?
 
Upvote 0
What about this question?
What version of Excel are you using?
It's just that if you are using Excel 2007 or later it has a built-in feature for removing duplicates - no need for IF formulas and helper columns. :)
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,348
Members
452,907
Latest member
Roland Deschain

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