Macro to add rows based on conditions and sum/subtotal lines above

boomerang_1

New Member
Joined
Jun 27, 2019
Messages
1
Hi All,
Just checking if anyone is able to assist me with setting up a code to add rows (based on a condition) and sum lines above.
Raw data is is below.

StateStoreStaff NameDayDateHours Category 1Hours Category 2Hours Category 3Hours Category 4
StateStore 1Staff 1Tuesday11/06/198.558.500.050.00
StateStore 1Staff 1Wednesday12/06/198.178.120.050.00
StateStore 1Staff 1Thursday13/06/196.326.320.000.00
StateStore 1Staff 1Friday14/06/198.328.300.020.00
StateStore 1Staff 1Saturday15/06/196.936.930.000.00
StateStore 1Staff 2Tuesday11/06/198.288.230.050.00
StateStore 1Staff 2Wednesday12/06/197.427.420.000.00
StateStore 1Staff 2Thursday13/06/196.486.480.000.00
StateStore 1Staff 3Friday14/06/193.273.270.000.00

<tbody>
</tbody>

I would like the macro to do the following;
> If staff1 works from Mon-Fri (weekday), then add row and sum hours (bold font & top border if possible)
> If staff1 works form Sat to/or Sun (weekend), do nothing (i.e. just list the hours)

Result:

StateStoreStaff NameDayDateHours Category 1Hours Category 2Hours Category 3Hours Category 4
StateStore 1Staff 1Tuesday11/06/198.558.500.050.00
StateStore 1Staff 1Wednesday12/06/198.178.120.050.00
StateStore 1Staff 1Thursday13/06/196.326.320.000.00
StateStore 1Staff 1Friday14/06/198.328.300.020.00
31.3531.230.120.00
StateStore 1Staff 1Saturday15/06/196.936.930.000.00
StateStore 1Staff 2Tuesday11/06/198.288.230.050.00
StateStore 1Staff 2Wednesday12/06/197.427.420.000.00
StateStore 1Staff 2Thursday13/06/196.486.480.000.00
22.1822.130.050.00
StateStore 1Staff 3Friday14/06/193.273.270.000.00
3.273.270.000.00

<tbody>
</tbody>

Thank you so much for your help.
 

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,334
Members
449,077
Latest member
Jocksteriom

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