VBA Loop with multiple conditions on one sheet

LovePenguin

New Member
Joined
Nov 15, 2018
Messages
1
Not sure if this is a duplicate question but couldn't seem to find it anywhere.

I have the following sample data:
ABCDEFGHI
1EMPLIDNAMEDeptLOCJOB TITLEEE STSEFFDTHIST EFFDTHIST EE STS
2123Doo, Scooby564564CDriverL4/28/20183/20/2017L
3123Doo, Scooby564564CDriverL4/28/20183/15/2017L
4456Jetson, Jane531531ProductionL4/28/20186/2/2017L
5456Jetson, Jane531531ProductionL4/28/20182/20/2017A
6456Jetson, Jane531531ProductionL4/28/20181/6/2017L
7456Jetson, Jane531531ProductionL4/28/20182/20/2012A
8789Bear, Grammy501501StockroomL10/18/201810/18/2018L
9789Bear, Grammy501501StockroomL10/18/20184/16/2018A
10789Bear, Grammy501501StockroomL10/18/20183/30/2018L
11321Fraggle, Mokey501501ProductionL6/2/20186/15/2007L
12321Fraggle, Mokey501501ProductionL6/2/20185/21/2007A

<tbody>
</tbody>


What I need is a script for the following based on the sample data above:
I am trying to find the earliest date on a L row prior to an A.

So Jane Jetson is showing 2 separate L statuses. I need the earliest Hist EFFDt from the latest L status (ie: 6/2/17) to be placed in the farthest column to the right (doesn't matter which line but I need all other lines for the employee to either be blank or that date). Once it finds that it needs to move on to Grammy Bear. You will notice that Scooby Doo doesn't have any A status. Therefore I need it to recognize that 3/15/17 is the correct date I need not 3/20/17.

I think I need several DoUntil Loops in addition to some offsets. However, I am a total newbie at VBA with only basic knowledge of Macros and a few reference books. I can't seem to figure out how to put it all together.

Please help!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,214,394
Messages
6,119,262
Members
448,880
Latest member
aveternik

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