Counting Holiday & Sunday as leaves

misrasomendra

Board Regular
Joined
Nov 17, 2012
Messages
74
Hi all excel experts,

Here I have a problem with counting number of leaves. Suppose below is my data
If you see I am counting total leaves for each employee. But here is one condition if between two leaves any sunday or any holiday will come that should also be counted as leaves.Like Name 2 there is one Holiday (H) and one Sunday(S) followed by and precedded by L. So they should also get counted as Leaves. There can be situations like PPLLLHHHLLLPP or PPPPLLSLPPH.
Emp Name12345678TOTAL LEAVE
Name 1PPLLHSPL3
Name 2PLLLHSLP6
Name 3PPPPHSPP0

<TBODY>
</TBODY>

Any help regarding what formula should deliver me the result. I think frequecy can do it but I am unable to figure out how?

Thanks in advance.

Regards!
SM.
 
Hi Markmzz,

Thanks again. Well VBA is another option I can use but I want a formula solution for this one. Lets wait for other experts to come up with their solution.

Regards.

Try this formula (without helper column):

Code:
In AG2 - use Ctrl+Shift+Enter and not only Enter to enter the formula

=SUM(LEN(AH2)-LEN(SUBSTITUTE(
SUBSTITUTE(B2&C2&D2&E2&F2&G2&H2&I2&J2&K2&L2&M2&N2&O2&P2&Q2&R2&S2&T2&U2&V2&W2&X2&Y2&Z2&AA2&AB2&AC2&AD2&AE2&AF2,"S","H"),
"L"&REPT("H",ROW($1:$29))&"L","LL",TRANSPOSE(ROW($1:$29)))))+COUNTIF(B2:AF2,"L")

And tell me if works.


Markmzz
 
Upvote 0

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.
A small modification in my last formula (now without helper column):

Code:
In AG2 - use Ctrl+Shift+Enter and not only Enter to enter the formula

=SUM(LEN(SUBSTITUTE(B2&C2&D2&E2&F2&G2&H2&I2&J2&K2&L2&M2&N2&O2&P2&Q2&R2&S2&T2&U2&V2&W2&X2&Y2&Z2&AA2&AB2&AC2&AD2&AE2&AF2,"S","H"))-
LEN(SUBSTITUTE(SUBSTITUTE(B2&C2&D2&E2&F2&G2&H2&I2&J2&K2&L2&M2&N2&O2&P2&Q2&R2&S2&T2&U2&V2&W2&X2&Y2&Z2&AA2&AB2&AC2&AD2&AE2&AF2,"S","H"),
"L"&REPT("H",ROW($1:$29))&"L","LL",TRANSPOSE(ROW($1:$29)))))+COUNTIF(B2:AF2,"L")

Markmzz
 
Upvote 0

Forum statistics

Threads
1,216,526
Messages
6,131,187
Members
449,631
Latest member
mehboobahmad

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