VBA Macro on copy pasting from one workbook to another with loop and conditions

hencra

New Member
Joined
Jan 25, 2017
Messages
2
Hi,
Can you help me with my problem, I want to automate the creation of a DTR given the schedule they have. I have the file where the schedule is in together with all other information called "DTR Creator" and a "DTR Sample" where the cells will be copied. I need to create N numbers of DTR equal to N numbers of employee
Things i need to copy;
Name of the employee from E3 up to the last row with data to be copied at D4 of DTR sample workbook
Date from H1 up to the the last column with data with 2 column spaces, so H1, J1, L1 etc to be copied from A9 to the last row with data of DTR Sample
We have three shifts, 8M, 8N and 8T and blank if dayoff
I have 4 columns in DTR sample where different conditions are needed for different shifts
Scheduled word hours
Total Worked Hours
Total ND Hours
Remarks
8M
Needs to have 8 under the scheduled hours column. data will be known from DTR creator H3 inline with the date, next is on J3 etc to be pasted on B9 downwards until there is data available
Total worked hours is 8 and should be pasted from f9 downwards on DTR Sample
Total ND hours is blank
Remarks is blank
8N
Needs to have 8 under the scheduled hours column. data will be known from DTR creator H3 inline with the date, next is on J3 etc to be pasted on B9 downwards until there is data available
Total worked hours is 8 and should be pasted from f9 downwards on DTR Sample
Total ND hours is 8 and should be pasted from g9 downwards
Remarks is Night Diff and should be pasted from h9 downwards
8T
Needs to have 8 under the scheduled hours column. data will be known from DTR creator H3 inline with the date, next is on J3 etc to be pasted on B9 downwards until there is data available
Total worked hours is 8 and should be pasted from f9 downwards on DTR Sample
Total ND hours is 3 and should be pasted from g9 downwards
Remarks is Night Diff and should be pasted from h9 downwards
After that, the dtr sample will be saveas with the name of the employee being copied then close and then goes next to the next row of the employee name like a loop until there is no more data.
Thanks in advance!

<colgroup><col span="5"></colgroup><tbody>
</tbody>
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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