Evaluate and delete rows

Truiz

Active Member
Joined
Jul 14, 2014
Messages
339
Good afternoon I have the following information.


Excel 2012
AHIJKL
1Store#Event DateEvent TimeCheck ColumnUserEvent Description
2STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 2001669947-Aug-178:36 AMNoUser #1Open
3STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 2001669947-Aug-178:21 PMYesUser#2Open
4STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 2001669948-Aug-178:43 AMNoUser #2Open
5STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 2001669948-Aug-178:12 PMYesUser#3Open
6STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 2001669949-Aug-178:41 AMNoUser #3Open
7STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 2001669949-Aug-177:54 PMYesUser[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL]Open
8STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 20016699410-Aug-178:57 AMYesUser [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL]Open
9STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 20016699410-Aug-178:53 PMYesUser#5Open
10STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 20016699411-Aug-178:46 AMYesUser #5Open
11STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 20016699411-Aug-178:40 PMYesUser#6Open
12STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 20016699412-Aug-178:40 AMNoUser #6Open
13STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 2001739356-Aug-179:31 AMNoUser#7Open
14STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 2001739357-Aug-177:51 AMNoUser #7Open
15STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 2001739358-Aug-178:45 AMNoUser#8Open
16STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 2001739359-Aug-178:19 AMNoUser #8Open
17STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 20017393510-Aug-178:26 AMNoUser#9Open
18STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 20017393511-Aug-178:45 AMNoUser #9Open
19STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 20017393512-Aug-178:29 AMNoUser#10Open
20STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 2001751047-Aug-178:35 AMNoUser #10Open
21STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 2001751047-Aug-178:35 PMYesUser#11Open
22STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 2001751048-Aug-178:45 AMNoUser #11Open
23STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 2001751048-Aug-177:51 PMYesUser#12Open
24STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 2001751049-Aug-178:37 AMNoUser #12Open
25STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 20017510410-Aug-178:44 AMNoUser#13Open
26STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 20017510411-Aug-178:46 AMYesUser #13Open
27STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 20017510412-Aug-178:22 AMNoUser#14Open
Open Closed Alarm




As you can see there are several stores each store might appear more than once for the same date what I want to do is have just one entry per store per date only the earliest entry so the outcome will be like this:



Excel 2012
AHIJKL
1Store#Event DateEvent TimeCheck ColumnUserEvent Description
2STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 2001669947-Aug-178:36 AMNoUser #1Open
3STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 2001669948-Aug-178:43 AMNoUser #2Open
4STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 2001669949-Aug-178:41 AMNoUser #3Open
5STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 20016699410-Aug-178:57 AMYesUser [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL]Open
6STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 20016699411-Aug-178:46 AMYesUser #5Open
7STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=35]#35[/URL] BOCA RATON 20016699412-Aug-178:40 AMNoUser #6Open
8STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 2001739356-Aug-179:31 AMNoUser#7Open
9STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 2001739357-Aug-177:51 AMNoUser #7Open
10STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 2001739358-Aug-178:45 AMNoUser#8Open
11STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 2001739359-Aug-178:19 AMNoUser #8Open
12STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 20017393510-Aug-178:26 AMNoUser#9Open
13STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 20017393511-Aug-178:45 AMNoUser #9Open
14STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4]#4[/URL] CORPUS CHRISTI 20017393512-Aug-178:29 AMNoUser#10Open
15STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 2001751047-Aug-178:35 AMNoUser #10Open
16STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 2001751048-Aug-178:45 AMNoUser #11Open
17STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 2001751049-Aug-178:37 AMNoUser #12Open
18STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 20017510410-Aug-178:44 AMNoUser#13Open
19STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 20017510411-Aug-178:46 AMYesUser #13Open
20STORE [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=32]#32[/URL] STOCKTON 20017510412-Aug-178:22 AMNoUser#14Open
Open Closed Alarm
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
If you always have them sorted like your example then you can use code like this:
Code:
Sub Test()


    Lrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
    
    For i = Lrow To 2 Step -1
        If ActiveSheet.Cells(i, "A") = ActiveSheet.Cells(i - 1, "A") Then 'Check the store to see if it's the same
            If ActiveSheet.Cells(i, "B") = ActiveSheet.Cells(i - 1, "B") Then 'Check the date to see if it's the same
                ActiveSheet.Cells(i, "A").EntireRow.Delete
            End If
        End If
    Next


End Sub
 
Upvote 0
Will this work if the store has let's say 5 entries with the same date?
how do I know the row getting deleted it's not the earliest?
 
Upvote 0
If you sort the data by store then by date then by time the earliest should always be "top of stack". In this scenario the rows getting deleted are the ones below this record... meaning that the code will work as expected.
 
Upvote 0

Forum statistics

Threads
1,216,086
Messages
6,128,736
Members
449,466
Latest member
Peter Juhnke

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