Formula to return a code per row based on multiple criteria and steps-EXPERT needed

Cyberpunk001

New Member
Joined
Aug 27, 2018
Messages
13
Good day Excel forum,

I need the help of an expert to solve a puzzling and challenging problem.

I will try to explain in the shortest way possible, but need to be thorough to explain in clarity.
In the table below, I have need of a formula in the "Code" column to do some very specific calculations regarding multiple criteria as outlined in the steps below.

[TABLE="width: 750, align: left"]
<tbody>[TR]
[TD]Emp ID[/TD]
[TD]Weeknum[/TD]
[TD]Hours[/TD]
[TD]Over[/TD]
[TD]Code[/TD]
[TD]Hours2[/TD]
[TD]Helper[/TD]
[/TR]
[TR]
[TD]1010x[/TD]
[TD]1[/TD]
[TD]2.5[/TD]
[TD]5.75[/TD]
[TD]1?[/TD]
[TD]2.5[/TD]
[TD]55[/TD]
[/TR]
[TR]
[TD]1010x[/TD]
[TD]1[/TD]
[TD]8[/TD]
[TD]5.75[/TD]
[TD]1?[/TD]
[TD]8[/TD]
[TD]55[/TD]
[/TR]
[TR]
[TD]1010x[/TD]
[TD]2[/TD]
[TD]9[/TD]
[TD]5.75[/TD]
[TD]1?[/TD]
[TD]9[/TD]
[TD]55[/TD]
[/TR]
[TR]
[TD]1010x[/TD]
[TD]3[/TD]
[TD]4.5[/TD]
[TD]5.75[/TD]
[TD]1?[/TD]
[TD]4.5[/TD]
[TD]55[/TD]
[/TR]
[TR]
[TD]1010x[/TD]
[TD]3[/TD]
[TD]4.5[/TD]
[TD]5.75[/TD]
[TD]1?[/TD]
[TD]4.5[/TD]
[TD]55[/TD]
[/TR]
[TR]
[TD]1010x[/TD]
[TD]4[/TD]
[TD]9.75[/TD]
[TD]5.75[/TD]
[TD]1?[/TD]
[TD]9.75[/TD]
[TD]55[/TD]
[/TR]
[TR]
[TD]1010x[/TD]
[TD]4[/TD]
[TD]1.5[/TD]
[TD]5.75[/TD]
[TD]2?[/TD]
[TD]5.75[/TD]
[TD]55[/TD]
[/TR]
[TR]
[TD]1010x[/TD]
[TD]6[/TD]
[TD]11[/TD]
[TD]5.75[/TD]
[TD]1?[/TD]
[TD]6.75[/TD]
[TD]55[/TD]
[/TR]
</tbody>[/TABLE]













Formula breakdown


1) Step 1 sum all hours by Emp ID and weeknum not equal to 7
2) Step 2 calculate overtime by summing difference between sum of hours and over column and deposit in "over" column
3) Step 3 check in "hours" column if a value exists which is the same as the "over" column, return TRUE, FALSE
4) step 4 if step 3 is TRUE, find the row where this value is stored in "hours" column and deposit value in same row of column "Hours2"
5) step 5 return code 1 in all rows for emp ID in column "Code" except for the value obtained in step 4, use code 2 instead
6) if a value for "over" does not exist in the "hours" column, replace the minimum value found for emp ID with real number in "Hours2" column from value in "over column"
7) step 7 replace maximum value in "Hours" column for Emp ID with 45-(helper column value-over value-max value in list)
8) return code 1 in all rows for Emp ID except the value obtained for "over" column, use code 2 instead

Any help will be greatly appreciated
smile.gif
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,223,888
Messages
6,175,205
Members
452,618
Latest member
Tam84

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