Copy Paste in another worksheet based on cell value vba

Penny110

New Member
Joined
Feb 26, 2015
Messages
3
Hi, I'm new to VBA but did quite a bit of macros last week with the help from this forum. Now I'm stuck with this one and can't figure it out. Any help is much appreciated.

I have a schedule something like this on Sheet1:</SPAN>
Name</SPAN>
Mon</SPAN>
Tue</SPAN>
Wed</SPAN>
John</SPAN>
Surrey 0900-1700</SPAN>
Van 1230-1945</SPAN>
APH 0745-1515</SPAN>
Sue</SPAN>
Surrey 0715-1600</SPAN>
APH 0900-1700</SPAN>
APH 0900-1700</SPAN>
Mike</SPAN>
APH 0715-1600</SPAN>
APH 0900-1700</SPAN>
APH 0745-1515</SPAN>
Dan</SPAN>
APH 0900-1700</SPAN>
Surrey 0715-1600</SPAN>

<TBODY>
</TBODY>

for each day of the week, shows the location and shift hours for each staff.
On Sheet2 = "Monday" I have the required shifts for each location on Mondays. something like this. I have 7 worksheets for 7 days of the week.</SPAN>
Mon</SPAN>
Mon</SPAN>
APH 0715-1600</SPAN>
Surrey 0715-1600</SPAN>
APH 0900-1700</SPAN>
Surrey 0715-1600</SPAN>
APH 0900-1700</SPAN>
Surrey 0900-1700</SPAN>
APH 0745-1515</SPAN>
Surrey 0900-1700</SPAN>
Surrey 0800-1730</SPAN>

<TBODY>
</TBODY>
I need a macro to get the value of the first required shift for APH location (APH 0715-1600) and search in Sheet1 under Mon column, find the value, copy the corresponding staff name and paste it on Sheet "Monday" beside the first required shift on the left side cell. Then this repeats for the second required shift and so on. Then should go to the next location i.e. Surrey and starts with first required shift for Surrey (Surrey 0715-1600) and ...

The result should be like:</SPAN>


Mon</SPAN>
Mon</SPAN>
Mike</SPAN>
APH 0715-1600</SPAN>
Sue</SPAN>
Surrey 0715-1600</SPAN>
Dan</SPAN>
APH 0900-1700</SPAN>
Surrey 0715-1600</SPAN>
APH 0900-1700</SPAN>
John</SPAN>
Surrey 0900-1700</SPAN>
APH 0745-1515</SPAN>
Surrey 0900-1700</SPAN>
Surrey 0800-1730</SPAN>

<TBODY>
</TBODY>


At the end I should know the required shifts that have no one assigned to and should be offered to staffs.

On Sheet1, not all staffs have an assigned shifts (some cells are blank). The cells are color coded by location.
On Sheet "Monday", there might be 2 or more of a same shift required.

Let me know if I need to provide more info.

Thanks in advance,</SPAN>
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,215,455
Messages
6,124,938
Members
449,197
Latest member
k_bs

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