VBA code across reading and dropping data across multiple sheets

Steve1208

New Member
Joined
Nov 10, 2017
Messages
28
Hello:

(Please note I will add an example of the workbook tomorrow) if anyone feels they have an answer from my description, I’d be very grateful for a response:

I have a workbook that is used as a calendar to manage a team of employees working across multiple contracts.

The workbook contains multiple sheets, which consist of:
Overview (summary sheet) this is what I need the VBA to populate.
Contract sheets (15 different contract sheets)

The overview (summary sheet) shows all the employees and indicates which contract each employee is working on, each day. It currently does this by a very long formula!, which looks over all the contract sheets (Which cannot be future proofed, for example if another contract sheet is added)

column A2:A25 (each row contains the name of the employee)

Columns B1:F1 contains the days Monday - Friday.

The contract sheets:
Each contract has its own sheet, the sheet is named as the contract.
The sheet comprises of the following information:

A2:A5 contains employee name (this is populated manually if the employee is working on that contract for anytime that week.

B1:F1 contains Monday-Friday.

The work content the employee is expected to complete is then input on the grid reference corresponding to the day and employee completing the task.

Therefore any one employee could be placed on any 15 contracts. For example employee 1 could be working on contract 5 on M, T & W and contract 8 on T & F.
Therefore this needs to refer back the the overview page to identify which employees are working on each contract.

The code I’m after needs to be a VBA that does the following:
Identifies an employee named on a contract and has tasks listed on seperate days.

Then populate this onto the summary sheet, by stating which contract the employee is working on each day. Furthermore i need the VBA future proofed, for example if another contract sheet is added the code will look at the new sheet too, with the same set of rules.

I hope that makes sense and would be very grateful for some help with this. As I mentioned I can solve the issue with a formula, however it needs to be VBA, to future proof the rule and also prevent users from knocking the formula out by mistake.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I understand this is a bit of a complex problem, please see below for further clarification:
The formula solves the problem, however I would prefer to see this in the form of VBA code:
This is located in the Employees Tab:
=IF(COUNTIF(AF3,"TRUE")>0,"OFF",IF(AND(COUNTIF('Contract 1'!$A$3:$A$38,FITTERS!$A3)>0,IFERROR(INDEX('Contract 1'!B$3:'Contract 1'!B$9:'Contract 1'!B$15:'Contract 1'!B$21:'Contract 1'!B$33,MATCH(FITTERS!$A3,'Contract 1'!$A$3:$A$38,0)),0)>0),'Contract 1'!$A$1,

IF(AND(COUNTIF('Contract 2'!$A$3:$A$32,FITTERS!$A3)>0,IFERROR(INDEX('Contract 2'!B$3:'Contract 2'!B$9:'Contract 2'!B$15:'Contract 2'!B$21:'Contract 2'!B$27,MATCH(FITTERS!$A3,'Contract 2'!$A$3:$A$32,0)),0)>0),'Contract 2'!$A$1,

IF(AND(COUNTIF('Contract 3'!$A$3:$A$32,FITTERS!$A3)>0,IFERROR(INDEX('Contract 3'!B$3:'Contract 3'!B$9:'Contract 3'!B$15:'Contract 3'!B$21:'Contract 3'!B$27,MATCH(FITTERS!$A3,'Contract 3'!$A$3:$A$32,0)),0)>0),'Contract 3'!$A$1,
IF(AND(COUNTIF('Contract 4'!$A$3:$A$32,FITTERS!$A3)>0,IFERROR(INDEX('Contract 4'!B$3:'Contract 4'!B$9:'Contract 4'!B$15:'Contract 4'!B$21:'Contract 4'!B$27,MATCH(FITTERS!$A3,'Contract 4'!$A$3:$A$32,0)),0)>0),'Contract 4'!$A$1,
IF(AND(COUNTIF('Contract 5'!$A$3:$A$32,FITTERS!$A3)>0,IFERROR(INDEX('Contract 5'!B$3:'Contract 5'!B$9:'Contract 5'!B$15:'Contract 5'!B$21:'Contract 5'!B$27,MATCH(FITTERS!$A3,'Contract 5'!$A$3:$A$32,0)),0)>0),'Contract 5'!$A$1,
IF(AND(COUNTIF('Contract 6'!$A$3:$A$32,FITTERS!$A3)>0,IFERROR(INDEX('Contract 6'!B$3:'Contract 6'!B$9:'Contract 6'!B$15:'Contract 6'!B$21:'Contract 6'!B$27,MATCH(FITTERS!$A3,'Contract 6'!$A$3:$A$32,0)),0)>0),'Contract 6'!$A$1,
IF(AND(COUNTIF('Contract 7'!$A$3:$A$32,FITTERS!$A3)>0,IFERROR(INDEX('Contract 7'!B$3:'Contract 7'!B$9:'Contract 7'!B$15:'Contract 7'!B$21:'Contract 7'!B$27,MATCH(FITTERS!$A3,'Contract 7'!$A$3:$A$32,0)),0)>0),'Contract 7'!$A$1,


IF(AND(COUNTIF('Contract 8'!$A$3:$A$32,FITTERS!$A3)>0,IFERROR(INDEX('Contract 8'!B$3:'Contract 8'!B$9:'Contract 8'!B$15:'Contract 8'!B$21:'Contract 8'!B$27,MATCH(FITTERS!$A3,'Contract 8'!$A$3:$A$32,0)),0)>0),'Contract 8'!$A$1,
IF(AND(COUNTIF('Contract 9'!$A$3:$A$32,FITTERS!$A3)>0,IFERROR(INDEX('Contract 9'!B$3:'Contract 9'!B$9:'Contract 9'!B$15:'Contract 9'!B$21:'Contract 9'!B$27,MATCH(FITTERS!$A3,'Contract 9'!$A$3:$A$32,0)),0)>0),'Contract 9'!$A$1,
IF(AND(COUNTIF('Contract 10'!$A$3:$A$32,FITTERS!$A3)>0,IFERROR(INDEX('Contract 10'!B$3:'Contract 10'!B$9:'Contract 10'!B$15:'Contract 10'!B$21:'Contract 10'!B$27,MATCH(FITTERS!$A3,'Contract 10'!$A$3:$A$32,0)),0)>0),'Contract 10'!$A$1,0)))))))))))

I have also attached the document in question:
https://www.dropbox.com/s/a6kwq566l6n8yoz/Formula%20Help%202.xlsm?dl=0
 
Upvote 0

Forum statistics

Threads
1,224,747
Messages
6,180,719
Members
452,995
Latest member
isldboy

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