Hi VBA masters.
I need some help with some more complex if then statements and movement of data amongst tabs based on those if then statements. Thank you in advance!!
The short: I seek to take a source file and split it up based on two scenarios.
1. If an Employee ID shows up once in Column C, then copy and paste entire row to Sheet 2.
2. If an Employee ID shows up more than once in Column C, then determine the instance with the oldest date in Column J (Grant Date), and copy and paste into Sheet 2, then the next oldest instance is copy and pasted into Sheet 3, then sheet 4, Etc. (There will never be more than 4 instances)
The Long:
I receive a file that contains a list of employees who have restricted stock that will vest on a particular date. (That date is titled "Purchase Date" and is in Column S (See below)
Duplicate employee IDs occur often as employees are granted stock on different dates and years, but the grants sometimes vest on the same date. An example is in the table below. See employee 2345 has 3 different grants dates that all vest on the same date in February. We must split these out into separate payrolls that are in order of grant date so taxes are calculated properly for each grant.
So, I was able to write a macro that splits the source file by grant date,...but that doesn't help my payroll team. That creates numerous tabs which equates to numerous off-cycle payrolls, reconciliations, etc. and just makes their job harder. We need to consolidate the data to limit the number of payroll runs the team must process. To do this, we need Sheet 2 to contain any employee who has just one vesting which could be 2000+ people). This sheet 2 must also include the first instance of any duplicates. Then all second instances go into sheet 3, all 3rd instances into sheet 4, etc.
In the below example sheet 2 will have employee 1234, first instance (grant date 6/30/2019) for employee 2345 and first instance of employee 6789 (Grant date 7/31/2019). Sheet 3 will be Employee 2345 instance 2 and employee 6789 instance 2, Sheet 4 will have 2345 instance 3. Notice the grant dates can be different by employee on each sheet. That is ok.
Thank you so much for any help you can provide.
I need some help with some more complex if then statements and movement of data amongst tabs based on those if then statements. Thank you in advance!!
The short: I seek to take a source file and split it up based on two scenarios.
1. If an Employee ID shows up once in Column C, then copy and paste entire row to Sheet 2.
2. If an Employee ID shows up more than once in Column C, then determine the instance with the oldest date in Column J (Grant Date), and copy and paste into Sheet 2, then the next oldest instance is copy and pasted into Sheet 3, then sheet 4, Etc. (There will never be more than 4 instances)
The Long:
I receive a file that contains a list of employees who have restricted stock that will vest on a particular date. (That date is titled "Purchase Date" and is in Column S (See below)
Duplicate employee IDs occur often as employees are granted stock on different dates and years, but the grants sometimes vest on the same date. An example is in the table below. See employee 2345 has 3 different grants dates that all vest on the same date in February. We must split these out into separate payrolls that are in order of grant date so taxes are calculated properly for each grant.
So, I was able to write a macro that splits the source file by grant date,...but that doesn't help my payroll team. That creates numerous tabs which equates to numerous off-cycle payrolls, reconciliations, etc. and just makes their job harder. We need to consolidate the data to limit the number of payroll runs the team must process. To do this, we need Sheet 2 to contain any employee who has just one vesting which could be 2000+ people). This sheet 2 must also include the first instance of any duplicates. Then all second instances go into sheet 3, all 3rd instances into sheet 4, etc.
In the below example sheet 2 will have employee 1234, first instance (grant date 6/30/2019) for employee 2345 and first instance of employee 6789 (Grant date 7/31/2019). Sheet 3 will be Employee 2345 instance 2 and employee 6789 instance 2, Sheet 4 will have 2345 instance 3. Notice the grant dates can be different by employee on each sheet. That is ok.
Thank you so much for any help you can provide.
Column B | Column J | Column S | Column W | |
Employee ID | Grant Date | Purchase Date | Qty-Vesting | |
1234 | 6/30/2019 | 2/28/2022 | 50 | |
2345 | 6/30/2019 | 2/28/2022 | 25 | |
2345 | 10/31/2019 | 2/28/2022 | 25 | |
2345 | 1/31/2020 | 2/28/2022 | 25 | |
6789 | 7/31/2019 | 2/28/2022 | 100 | |
6789 | 7/31/2021 | 2/28/2022 | 100 |