Need a macro to insert multiple lines and copy data at change in emp no.

starrfire

New Member
Joined
Jul 17, 2013
Messages
8
I need to enter leave for all my employees for our christmas closedown.
I have a list of staff numbers and then I need to insert lines with the time off dates
eg
Simple staff list downloaded:
105284
105239
005683
etc

Need it to end up being like this table below so that I can upload it into our HRIS system. So at each change in employee number I need to insert 3 columns with Date, time off category and amount, with the dates as set below and each individual line needs to have the employee number. As it will be a csv file, I need to keep leading zeroes, and the date needs to be in the american format mm/dd/yyyy.

I would really appreciate your help. I have tinkered for a while and can do certain things like insert lines and do offsets and copy data, but I've lost my way adding in the employee numbers in each row. Macros are definitely not my strong suit I'm afraid.
Employee #DateTime off categoryAmount
105284​
12/25/2022​
Annual Leave
0​
105284​
12/26/2022​
Annual Leave
0​
105284​
12/27/2022​
Annual Leave
1​
105284​
12/28/2022​
Annual Leave
1​
105284​
12/29/2022​
Annual Leave
1​
105284​
01/03/2023​
Annual Leave
0​
105284​
01/04/2023​
Annual Leave
0​
105284​
01/05/2023​
Annual Leave
1​
105284​
01/06/2023​
Annual Leave
1​
105284​
01/07/2023​
Annual Leave
1​
105284​
01/10/2023​
Annual Leave
1​
105284​
01/11/2023​
Annual Leave
1​
105284​
01/12/2023​
Annual Leave
1​
105284​
01/13/2023​
Annual Leave
1​
105284​
01/14/2023​
Annual Leave
1​
105284​
01/15/2023​
Annual Leave
1​
105239​
12/25/2022​
Annual Leave
0​
105239​
12/26/2022​
Annual Leave
0​
105239​
12/27/2022​
Annual Leave
1​
105239​
12/28/2022​
Annual Leave
1​
105239​
12/29/2022​
Annual Leave
1​
105239​
01/03/2023​
Annual Leave
0​
105239​
01/04/2023​
Annual Leave
0​
105239​
01/05/2023​
Annual Leave
1​
105239​
01/06/2023​
Annual Leave
1​
105239​
01/07/2023​
Annual Leave
1​
105239​
01/10/2023​
Annual Leave
1​
105239​
01/11/2023​
Annual Leave
1​
105239​
01/12/2023​
Annual Leave
1​
105239​
01/13/2023​
Annual Leave
1​
105239​
01/14/2023​
Annual Leave
1​
105239​
01/15/2023​
Annual Leave
1​
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,223,247
Messages
6,171,004
Members
452,374
Latest member
keccles

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