Hi, I have a payroll spreadsheet and we have had instances where employees have not been processed for a week because they have been on holiday and so have not submitted a timesheet. I therefore want to put in some code to run when the workbook is shut to check if all the names in the 'Lists' table have an entry against them on the 'Data' sheet for the week in the last row. My data that looks like this:
Lists worksheet
[TABLE="width: 500"]
<tbody>[TR]
[TD]A[/TD]
[/TR]
[TR]
[TD]Mr A[/TD]
[/TR]
[TR]
[TD]Mr B[/TD]
[/TR]
[TR]
[TD]Mr C[/TD]
[/TR]
</tbody>[/TABLE]
Data worksheet
[TABLE="width: 500"]
<tbody>[TR]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]Mr A[/TD]
[TD]1/5/18[/TD]
[/TR]
[TR]
[TD]Mr B[/TD]
[TD]1/5/18[/TD]
[/TR]
[TR]
[TD]Mr C[/TD]
[TD]1/5/18[/TD]
[/TR]
[TR]
[TD]Mr A[/TD]
[TD]8/5/18[/TD]
[/TR]
[TR]
[TD]Mr C[/TD]
[TD]8/5/18[/TD]
[/TR]
</tbody>[/TABLE]
On closing the workbook the macro should find the date in column D of the last row, and check that all employees listed in column A on the Lists tab have an entry with that date on the data tab - in the above Mr B doesn't ahve an entry for the 8th of May and so would display a message box saying that.
If anyone has 5 minutes and can help would be very grateful,
Thanks
Lists worksheet
[TABLE="width: 500"]
<tbody>[TR]
[TD]A[/TD]
[/TR]
[TR]
[TD]Mr A[/TD]
[/TR]
[TR]
[TD]Mr B[/TD]
[/TR]
[TR]
[TD]Mr C[/TD]
[/TR]
</tbody>[/TABLE]
Data worksheet
[TABLE="width: 500"]
<tbody>[TR]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]Mr A[/TD]
[TD]1/5/18[/TD]
[/TR]
[TR]
[TD]Mr B[/TD]
[TD]1/5/18[/TD]
[/TR]
[TR]
[TD]Mr C[/TD]
[TD]1/5/18[/TD]
[/TR]
[TR]
[TD]Mr A[/TD]
[TD]8/5/18[/TD]
[/TR]
[TR]
[TD]Mr C[/TD]
[TD]8/5/18[/TD]
[/TR]
</tbody>[/TABLE]
On closing the workbook the macro should find the date in column D of the last row, and check that all employees listed in column A on the Lists tab have an entry with that date on the data tab - in the above Mr B doesn't ahve an entry for the 8th of May and so would display a message box saying that.
If anyone has 5 minutes and can help would be very grateful,
Thanks
Last edited: