Simon2001
New Member
- Joined
- Jun 28, 2019
- Messages
- 16
- Office Version
- 365
- Platform
- Windows
Hi
I've got a spreadsheet, close to 50,000 rows, for which I have a VBA macro to autofilter on a certain criteria to reduce the number of rows (by deleting) to only have the ones I want left.
I now want to have the macro loop through the list to delete rows based on criteria in three colkumns, IF the same criteria appears in later rows further down the sheet. Hope this makes sense.
[TABLE="width: 301"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Employee 1[/TD]
[TD]Course 1[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Employee 1[/TD]
[TD]Course 2[/TD]
[TD]Not Completed[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Employee 1[/TD]
[TD]Course 3[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Employee 1[/TD]
[TD]Course 4[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Employee 2[/TD]
[TD]Course 1[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Employee 3[/TD]
[TD]Course 1[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Employee 1[/TD]
[TD]Course 2[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Employee 2[/TD]
[TD]Course 2[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]Employee 2[/TD]
[TD]Course 3[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]Employee 1[/TD]
[TD]Course 5[/TD]
[TD]Completed[/TD]
[/TR]
</tbody>[/TABLE]
In this case, Employee 1 did not complete a training course (row 2) but did complete it later (Row 7).
I want the macro to loop down row by row to see if it can find all cases when an employee did not complete a course but did later on. I want it then to delete the first incomplete row (but only if it recurs later as completed). So in this case delete row 2 only for that employee. Then continue through the rest of the sheet.
Im fairly ok with the looping code, etc but not sure on what I need to do do to get it to scan down for the criteria.
Any ideas?
Thanks
I've got a spreadsheet, close to 50,000 rows, for which I have a VBA macro to autofilter on a certain criteria to reduce the number of rows (by deleting) to only have the ones I want left.
I now want to have the macro loop through the list to delete rows based on criteria in three colkumns, IF the same criteria appears in later rows further down the sheet. Hope this makes sense.
[TABLE="width: 301"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Employee 1[/TD]
[TD]Course 1[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Employee 1[/TD]
[TD]Course 2[/TD]
[TD]Not Completed[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Employee 1[/TD]
[TD]Course 3[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Employee 1[/TD]
[TD]Course 4[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Employee 2[/TD]
[TD]Course 1[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Employee 3[/TD]
[TD]Course 1[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Employee 1[/TD]
[TD]Course 2[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Employee 2[/TD]
[TD]Course 2[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]Employee 2[/TD]
[TD]Course 3[/TD]
[TD]Completed[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]Employee 1[/TD]
[TD]Course 5[/TD]
[TD]Completed[/TD]
[/TR]
</tbody>[/TABLE]
In this case, Employee 1 did not complete a training course (row 2) but did complete it later (Row 7).
I want the macro to loop down row by row to see if it can find all cases when an employee did not complete a course but did later on. I want it then to delete the first incomplete row (but only if it recurs later as completed). So in this case delete row 2 only for that employee. Then continue through the rest of the sheet.
Im fairly ok with the looping code, etc but not sure on what I need to do do to get it to scan down for the criteria.
Any ideas?
Thanks