Truncate and count names

mwvirk

Active Member
Joined
Mar 2, 2011
Messages
298
Office Version
  1. 2016
Platform
  1. Windows
First scenario is...

I have mix names in:
Cell B1 Abc+Def+Xyz and a Date in A1
Cell B2 Def+Ghi and a Date in A2
Cell B3 Abc+Xyz and a Date in A3
Cell B4 Def+Ghi and a Date in A4

In C1 I want to count how many times Abc is present from B1:B4

In C2 want to count how many times Def is present from B1:B4

In C3 I want to count how many times Ghi is present from B1:B4

In C4 I want to count how many times Xyz is present from B1:B4


Second scenario is...

I have mix names in:

Cell B1 Abc+Def+Xyz and a Date in A1
Cell B2 Def+Ghi and a Date in A2
Cell B3 Abc+Xyz and a Date in A3
Cell B4 Def+Ghi and a Date in A4

In C1 I want to count how many times Abc is present from B1:B4 on next date

In C2 want to count how many times Def is present from B1:B4 on next date

In C3 I want to count how many times Ghi is present from B1:B4 on next date

In C4 I want to count how many times Xyz is present from B1:B4 on next date


(Please note that first scenario is for day shift from 4 pm to 12 am (16:00 to 24:00)

(but in second scenario the duty for the night shift start after 00:00 hrs so date 1 will be counted as date 2)
 
Can you please provide some sample data for the two scenarios, and the results you expect to see, using XL2BB - Excel Range to BBCode

Otherwise it's not at clear what you're asking, or what you mean by "next date", "date 1" and "date 2".
thank you.

Let me explain the first step...
I am receiving data from another system where staff names are showing like staff1+staff2 so I need to count each staff attendance
I am checking how many times a person is working in which shift
if the value in C is W then it's a normal working day and if it's P then it will be considered a public holiday

I will count how many times a person works the morning shift. if in C value is W then it will be in 'Morning' but if a value in C is P or it's Fri or Sat then it will be considered as 'Weekend Morning'
The same will apply for 'Afternoon' and Weekend Afternoon' and for 'Night' and 'Weekend Night' but for the Night Shift, duty starts after midnight 00:00hrs so calculation/attendance and payable amount will be as of the next day. i.e. if someone worked on Thursday night shift then it will be considered day Friday and it will fall in 'Weekend Night'

Note: I will calculate but no amount will be paid if staff is on duty in the morning during work days (Sun - Thu) but if it's Fri or Sat or a Public holiday, he will be in "Weekend Morning"

I would appreciate it if you could help resolve it. let me know if my message is clear now. Thanks


Book1
ABCDEFGHIJKLMN
1MorningAfternoonNight
2Sat01-Feb-2025WAbc+DefGhi+JklMno+PqrShift Days
3Sun02-Feb-2025WAbc+DefGhi+JklMno+Pqr Morning Weekend MorningAfternoonWeekend AfternoonNightWeekend Night
4Mon03-Feb-2025WStu+VwxXyzAbcdAbc111100
5Tue04-Feb-2025WStu+VwxXyzAbcdDef111103
6Wed05-Feb-2025WMno+PqrAbc+DefGhi+JklGhi001111
7Thu06-Feb-2025PMno+PqrAbc+DefGhi+JklJkl001111
8Mno110011
9Pqr110011
10Stu200000
11Vwx200000
12Xyz002000
13Abcd000020
14
15Shift Amount Calculation
16Weekend Morning AfternoonWeekend AfternoonNightWeekend NightTotal Of Amount
17Abc412140030
18Def4121404878
19Ghi01214141656
20Jkl01214141656
21Mno400141634
22Pqr400141634
23Stu000000
24Vwx000000
25Xyz02400024
26Abcd00028028
Sheet1
Cell Formulas
RangeFormula
A2:A7A2=TEXT(B2,"DDD")
I17:I26I17=J4*8*0.5
J17:J26J17=K4*8*1.5
K17:L26K17=L4*8*1.75
M17:M26M17=N4*8*2
N17:N26N17=SUM(I17:M17)
 
Upvote 0
Thanks, that's much clearer.

How about:

ABCDEFGHIJKLMNO
1MorningAfternoonNight
2Sat1 Feb 2025WAbc+DefGhi+JklMno+PqrShift Days
3Sun2 Feb 2025WAbc+DefGhi+JklMno+PqrMorningWeekend MorningAfternoonWeekend AfternoonNightWeekend Night
4Mon3 Feb 2025WStu+VwxXyzAbcdAbc111100
5Tue4 Feb 2025WStu+VwxXyzAbcdDef111100
6Wed5 Feb 2025WMno+PqrAbc+DefGhi+JklGhi001111
7Thu6 Feb 2025PMno+PqrAbc+DefGhi+JklJkl001111
8Mno110020
9Pqr110020
10Stu200000
11Vwx200000
12Xyz002000
13Abcd000020
14
15ShiftHours8
16Loading0.501.501.751.752.00
17
18Shift Amount Calculation
19Weekend MorningAfternoonWeekend AfternoonNightWeekend NightTotal Of Amount
20Abc412140030
21Def412140030
22Ghi01214141656
23Jkl01214141656
24Mno40028032
25Pqr40028032
26Stu000000
27Vwx000000
28Xyz02400024
29Abcd00028028
30
Sheet1
Cell Formulas
RangeFormula
I4:I13I4=SUMPRODUCT(--ISNUMBER(FIND("+"&$H4&"+","+"&D$2:D$7&"+")),--($C$2:$C$7="W"),--(WEEKDAY($B$2:$B$7)<6))
J4:J13J4=SUMPRODUCT(--ISNUMBER(FIND("+"&$H4&"+","+"&D$2:D$7&"+")))-I4
K4:K13K4=SUMPRODUCT(--ISNUMBER(FIND("+"&$H4&"+","+"&E$2:E$7&"+")),--($C$2:$C$7="W"),--(WEEKDAY($B$2:$B$7)<6))
L4:L13L4=SUMPRODUCT(--ISNUMBER(FIND("+"&$H4&"+","+"&E$2:E$7&"+")))-K4
M4:M13M4=SUMPRODUCT(--ISNUMBER(FIND("+"&$H4&"+","+"&F$2:F$7&"+")),--($C$2:$C$7="W"),--(WEEKDAY($B$2:$B$7,16)<6))
N4:N13N4=SUMPRODUCT(--ISNUMBER(FIND("+"&$H4&"+","+"&F$2:F$7&"+")))-M4
A2:A7A2=TEXT(B2,"DDD")
J20:N29J20=J4*$J$15*J$16
O20:O29O20=SUM(J20:N20)

I have assumed that:

- Names will be in exactly this format: Abc+Def+Mno, and not, for example: Abc + Def &Mno. In practice, I'd expect data entry variations to occur.
- Column C can contain only W or P - and hence that if the entry is not W it must be P.

Are your loadings correct, e.g. for an afternoon shift, is the loading 1.50, or the pay rate 1.50 and hence the loading 0.50?
 
Upvote 0

Forum statistics

Threads
1,226,771
Messages
6,192,926
Members
453,767
Latest member
922aloose

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