Look for a Value in Column B and Delete Rows after Comparing Values in Column C

Plokimu77

Board Regular
Joined
Oct 1, 2014
Messages
138
Hello Folks,

I was wondering if it could be possible to create a VBA code that would:
  1. Find a specific value in Column B
  2. Compare the times stamps in Column C
  3. And delete old rows except the row with the oldest timestamp
Below are 2 tables that I hope will help explain my situation.
I have to go through thousand of rows and it's taking forever.

Hopefully someone can kindly help.

Thank you.


Here are the steps I hope the code can perform:

A side note : All groups are separated by and empty row.
  1. Find all Rows with Values that contain value 10-B in Column B
  2. If only one value of 10-B is found in Column B, move to the next grouping
  3. If multiple values of 10-B are found in Column B, then look for the oldest time stamp in Column B, and delete all other rows containg 10-B
  4. Repeat steps 2-4 in the next grouping


Raw Table

A
B
C
1EventTime
203-A9/12/2023 09:11:59.000
310-B9/12/2023 19:58:56.000
410-B9/12/2023 20:02:06.000
510-B9/12/2023 20:03:57.000
610-B9/12/2023 20:08:27.000
725-C9/14/2023 04:08:07.000
8
903-A9/12/2023 09:11:59.000
1010-B9/12/2023 20:02:06.000
1125-C9/14/2023 04:08:07.000
12
1303-A9/12/2023 09:11:59.000
1410-B9/12/2023 19:58:56.000
1510-B9/12/2023 20:02:06.000
1625-C9/14/2023 04:08:07.000


Final Result:

A​
B​
C​
1EventTime
203-A9/12/2023 09:11:59.000
310-B9/12/2023 19:58:56.000
725-C9/14/2023 04:08:07.000
8
903-A9/12/2023 09:11:59.000
1010-B9/12/2023 20:02:06.000
1125-C9/14/2023 04:08:07.000
12
1303-A9/12/2023 09:11:59.000
1410-B9/12/2023 19:58:56.000
1625-C9/14/2023 04:08:07.000
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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