Macro for retaining one row of data per person

Gollum9

New Member
Joined
Feb 10, 2011
Messages
31
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have a large data set of training information, where there are individual rows per completion. The issue I have is that there can be multiple rows per person as they may have attempted the training before.

What I'm after if possible is some code that will only retain one row of information per person, based on the following rules. The data is in the format of Unique Person ID in column W, the date in column B, and the training status in column T (either passed or failed).

1) Retain only the most recent row for the person that has 'training status' = passed
2) If the person does not have a row with 'training status' = passed, delete all rows other than the most recent row with 'training status' = failed

Thanks for any advice you can provide.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 1
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Good thinking, all done now - thanks!
 
Upvote 0
Thanks.

Are you able to post some sample data, so we can see the full size of it? If not, can you at least let us know where exactly this data exists (row and column addresses)?

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
One other question - is it possible that a user would ever have a "passed" and "failed" record with the same date for each?
 
Upvote 0
One other question - is it possible that a user would ever have a "passed" and "failed" record with the same date for each?
I'm just trying to get you a sample of the data with nothing secure in there now.

And yes, it's possible they could have a passed and failed entry on the same say (although unlikely)
 
Upvote 0
I'm just trying to get you a sample of the data with nothing secure in there now.

And yes, it's possible they could have a passed and failed entry on the same say (although unlikely)
consu2096r1 (8).xlsx
ABCDEFGHIJKLMNOPQRSTUVW
1
2eLearning
3Record IDDateScoreTitleFirst nameLast nameEmp TypeLocationManager IDD1D2AreaTeamLevelMgrMgr First NameMgr Last NameMgr E-mailRoleStatusOffline DateOffline UserUnique Emp ID
4126-06-2023100Passed5440505
5226-06-2023100Passed2935
6326-06-2023100Passed2935
7426-06-2023100Passed6306
8526-06-2023100Passed46525
9626-06-20230Failed8403
10726-06-20230Failed43003
11826-06-2023100Passed5317098
12926-06-20230Failed18309
131026-06-20230Failed89786
141126-06-2023100Passed5074014
151226-06-2023100Passed1457
161326-06-20230Failed10816
171426-06-20230Failed498
181525-06-20230Failed5440505
191625-06-2023100Passed94904
201725-06-2023100Passed20522
211825-06-2023100Passed74576
221925-06-2023100Passed96171
232025-06-2023100Passed77288
242125-06-2023100Passed65425
252225-06-20230Failed5449003
262325-06-20230Failed18048
272425-06-2023100Passed5205524
282524-06-20230Failed5421184
292624-06-2023100Passed65684
302724-06-20230Failed5150329
312824-06-2023100Passed9896
322924-06-2023100Passed5368557
333024-06-20230Failed97824
343124-06-2023100Passed80956
353224-06-20230Failed96796
363324-06-2023100Passed8009
373424-06-2023100Passed5131045
383524-06-20230Failed19547
393624-06-2023100Passed5210245
403724-06-20230Failed11064
413824-06-2023100Passed5421641
423923-06-20230Failed46341
434023-06-2023100Passed16588
444123-06-2023100Passed5367543
454223-06-20230Failed89966
464323-06-20230Failed5380689
474423-06-202329Failed5456346
484523-06-2023100Passed5138112
494623-06-2023100Passed5455097
504723-06-2023100Passed5437543
514823-06-20230Failed80724
524923-06-2023100Passed5448990
535023-06-2023100Passed5449096
545123-06-20230Failed75584
555223-06-2023100Passed5435723
565323-06-20230Failed5346807
575423-06-20230Failed35690
585522-06-20230Failed3366
595622-06-2023100Passed5440475
605722-06-20230Failed7406
615822-06-2023100Passed212232
625922-06-20230Failed2701
636022-06-20230Failed5375616
646122-06-2023100Passed5437567
656222-06-20230Failed73141
666322-06-2023100Passed5433989
676422-06-2023100Passed5448921
686522-06-20230Failed64310
696622-06-20230Failed94153
706722-06-2023100Passed5471424
716822-06-2023100Passed5447801
726922-06-2023100Passed6961
737022-06-20230Failed73036
747122-06-20230Failed6324
757221-06-20230Failed5261056
767321-06-20230Failed35669
777421-06-20230Failed35669
787521-06-20230Failed5606
797621-06-20230Failed5170372
807721-06-20230Failed132436
817821-06-202358Failed68499
827921-06-20230Failed90431
838021-06-2023100Passed5434917
848121-06-2023100Passed5458623
858221-06-2023100Passed5456049
868321-06-20230Failed5273431
878421-06-2023100Passed5462682
888521-06-2023100Passed4158
898621-06-20230Failed12863
908721-06-20230Failed6319
918821-06-2023100Passed20579
928920-06-2023100Passed6319
939020-06-2023100Passed5313939
949120-06-20230Failed4981
959220-06-2023100Passed86315
969320-06-2023100Passed16895
979420-06-2023100Passed22745
989520-06-20230Failed5457909
999620-06-20230Failed9923
1009720-06-20230Failed97823
Report
 
Upvote 0
Thanks for your help @Joe4. Hopefully this shows enough of the file for you. I could only add 100 rows so there may not be many duplicates to test, but I hope it gives an idea.
 
Upvote 0
OK. Thanks. Give me a little bit to work on it. I have some ideas, but they take a little work.
 
Upvote 1

Forum statistics

Threads
1,215,219
Messages
6,123,681
Members
449,116
Latest member
HypnoFant

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