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:
[TABLE="class: grid, width: 614"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]EMPLID[/TD]
[TD]NAME[/TD]
[TD]Dept[/TD]
[TD]LOC[/TD]
[TD]JOB TITLE[/TD]
[TD]EE STS[/TD]
[TD]EFFDT[/TD]
[TD]HIST EFFDT[/TD]
[TD]HIST EE STS[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]123[/TD]
[TD]Doo, Scooby[/TD]
[TD]564[/TD]
[TD]564C[/TD]
[TD]Driver[/TD]
[TD]L[/TD]
[TD="align: right"]4/28/2018[/TD]
[TD="align: right"]3/20/2017[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]123[/TD]
[TD]Doo, Scooby[/TD]
[TD]564[/TD]
[TD]564C[/TD]
[TD]Driver[/TD]
[TD]L[/TD]
[TD="align: right"]4/28/2018[/TD]
[TD="align: right"]3/15/2017[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]456[/TD]
[TD]Jetson, Jane[/TD]
[TD]531[/TD]
[TD]531[/TD]
[TD]Production[/TD]
[TD]L[/TD]
[TD="align: right"]4/28/2018[/TD]
[TD="align: right"]6/2/2017[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]456[/TD]
[TD]Jetson, Jane[/TD]
[TD]531[/TD]
[TD]531[/TD]
[TD]Production[/TD]
[TD]L[/TD]
[TD="align: right"]4/28/2018[/TD]
[TD="align: right"]2/20/2017[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]456[/TD]
[TD]Jetson, Jane[/TD]
[TD]531[/TD]
[TD]531[/TD]
[TD]Production[/TD]
[TD]L[/TD]
[TD="align: right"]4/28/2018[/TD]
[TD="align: right"]1/6/2017[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]456[/TD]
[TD]Jetson, Jane[/TD]
[TD]531[/TD]
[TD]531[/TD]
[TD]Production[/TD]
[TD]L[/TD]
[TD="align: right"]4/28/2018[/TD]
[TD="align: right"]2/20/2012[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]789[/TD]
[TD]Bear, Grammy[/TD]
[TD]501[/TD]
[TD]501[/TD]
[TD]Stockroom[/TD]
[TD]L[/TD]
[TD="align: right"]10/18/2018[/TD]
[TD="align: right"]10/18/2018[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]789[/TD]
[TD]Bear, Grammy[/TD]
[TD]501[/TD]
[TD]501[/TD]
[TD]Stockroom[/TD]
[TD]L[/TD]
[TD="align: right"]10/18/2018[/TD]
[TD="align: right"]4/16/2018[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]789[/TD]
[TD]Bear, Grammy[/TD]
[TD]501[/TD]
[TD]501[/TD]
[TD]Stockroom[/TD]
[TD]L[/TD]
[TD="align: right"]10/18/2018[/TD]
[TD="align: right"]3/30/2018[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]321[/TD]
[TD]Fraggle, Mokey[/TD]
[TD]501[/TD]
[TD]501[/TD]
[TD]Production[/TD]
[TD]L[/TD]
[TD="align: right"]6/2/2018[/TD]
[TD="align: right"]6/15/2007[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]321[/TD]
[TD]Fraggle, Mokey[/TD]
[TD]501[/TD]
[TD]501[/TD]
[TD]Production[/TD]
[TD]L[/TD]
[TD="align: right"]6/2/2018[/TD]
[TD="align: right"]5/21/2007[/TD]
[TD]A[/TD]
[/TR]
</tbody>[/TABLE]
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!
I have the following sample data:
[TABLE="class: grid, width: 614"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]I[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]EMPLID[/TD]
[TD]NAME[/TD]
[TD]Dept[/TD]
[TD]LOC[/TD]
[TD]JOB TITLE[/TD]
[TD]EE STS[/TD]
[TD]EFFDT[/TD]
[TD]HIST EFFDT[/TD]
[TD]HIST EE STS[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]123[/TD]
[TD]Doo, Scooby[/TD]
[TD]564[/TD]
[TD]564C[/TD]
[TD]Driver[/TD]
[TD]L[/TD]
[TD="align: right"]4/28/2018[/TD]
[TD="align: right"]3/20/2017[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]123[/TD]
[TD]Doo, Scooby[/TD]
[TD]564[/TD]
[TD]564C[/TD]
[TD]Driver[/TD]
[TD]L[/TD]
[TD="align: right"]4/28/2018[/TD]
[TD="align: right"]3/15/2017[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]456[/TD]
[TD]Jetson, Jane[/TD]
[TD]531[/TD]
[TD]531[/TD]
[TD]Production[/TD]
[TD]L[/TD]
[TD="align: right"]4/28/2018[/TD]
[TD="align: right"]6/2/2017[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]456[/TD]
[TD]Jetson, Jane[/TD]
[TD]531[/TD]
[TD]531[/TD]
[TD]Production[/TD]
[TD]L[/TD]
[TD="align: right"]4/28/2018[/TD]
[TD="align: right"]2/20/2017[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]456[/TD]
[TD]Jetson, Jane[/TD]
[TD]531[/TD]
[TD]531[/TD]
[TD]Production[/TD]
[TD]L[/TD]
[TD="align: right"]4/28/2018[/TD]
[TD="align: right"]1/6/2017[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]456[/TD]
[TD]Jetson, Jane[/TD]
[TD]531[/TD]
[TD]531[/TD]
[TD]Production[/TD]
[TD]L[/TD]
[TD="align: right"]4/28/2018[/TD]
[TD="align: right"]2/20/2012[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]789[/TD]
[TD]Bear, Grammy[/TD]
[TD]501[/TD]
[TD]501[/TD]
[TD]Stockroom[/TD]
[TD]L[/TD]
[TD="align: right"]10/18/2018[/TD]
[TD="align: right"]10/18/2018[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]789[/TD]
[TD]Bear, Grammy[/TD]
[TD]501[/TD]
[TD]501[/TD]
[TD]Stockroom[/TD]
[TD]L[/TD]
[TD="align: right"]10/18/2018[/TD]
[TD="align: right"]4/16/2018[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]789[/TD]
[TD]Bear, Grammy[/TD]
[TD]501[/TD]
[TD]501[/TD]
[TD]Stockroom[/TD]
[TD]L[/TD]
[TD="align: right"]10/18/2018[/TD]
[TD="align: right"]3/30/2018[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]321[/TD]
[TD]Fraggle, Mokey[/TD]
[TD]501[/TD]
[TD]501[/TD]
[TD]Production[/TD]
[TD]L[/TD]
[TD="align: right"]6/2/2018[/TD]
[TD="align: right"]6/15/2007[/TD]
[TD]L[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]321[/TD]
[TD]Fraggle, Mokey[/TD]
[TD]501[/TD]
[TD]501[/TD]
[TD]Production[/TD]
[TD]L[/TD]
[TD="align: right"]6/2/2018[/TD]
[TD="align: right"]5/21/2007[/TD]
[TD]A[/TD]
[/TR]
</tbody>[/TABLE]
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!