SUM numbers in row with leading string character

strooman

Active Member
Joined
Oct 29, 2013
Messages
333
Office Version
  1. 2016
Platform
  1. Windows
I want to SUM the numbers in a row which represent the worked hours in a month. The numbers in the cells have a leading string character like V8 or S8 or H7,2. How can I do that. See the mini sheet below for layout and desired results. Thank you very much.

JusKaart.xlsm
DEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAM
19Desired outcome
2012345678910111213141516171819202122232425262728293031workedvacationholidaysick
21H7,211,07,07,09,08,07,58,010,07,54,02,07,510,08,02,07,58,08,0132,007,20
2211,07,58,07,58,07,57,58,010,07,57,08,0S8S8S8z84,08,0V8109,508,0024,00
23V4V4V4V8V8V8V7,2V7,2V7,2V8V8V88,08,08,08,011,07,550,5081,60
248,08,0H7,28,0H7,2H7,28,05,57,08,010,08,01,55,010,08,0H7,28,08,0111,0028,80
258,0H7,211,07,56,58,04,04,08,010,08,0H7,24,07,58,011,07,58,0H7,2H7,26,5127,5028,80
Bert
 

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.
I've assumed your Data begins in Cell A1, just put below formulae starts AF2 Respectively

worked (Column AF)vacation
(Column AG)
holiday
(Column AH)
sick
(Column AI)
=SUM(A2:AE2)=COUNTIFS(A2:AE2,"V8")*8+COUNTIFS(A2:AE2,"V4")*4+COUNTIFS(A2:AE2,"V7,2")*7.2=COUNTIFS(A2:AE2,"H7,2")*7.2=COUNTIFS(A2:AE2,"S8")*8
=SUM(A3:AE3)=COUNTIFS(A3:AE3,"V8")*8+COUNTIFS(A3:AE3,"V4")*4+COUNTIFS(A3:AE3,"V7,2")*7.2=COUNTIFS(A3:AE3,"H7,2")*7.2=COUNTIFS(A3:AE3,"S8")*8
=SUM(A4:AE4)=COUNTIFS(A4:AE4,"V8")*8+COUNTIFS(A4:AE4,"V4")*4+COUNTIFS(A4:AE4,"V7,2")*7.2=COUNTIFS(A4:AE4,"H7,2")*7.2=COUNTIFS(A4:AE4,"S8")*8
=SUM(A5:AE5)=COUNTIFS(A5:AE5,"V8")*8+COUNTIFS(A5:AE5,"V4")*4+COUNTIFS(A5:AE5,"V7,2")*7.2=COUNTIFS(A5:AE5,"H7,2")*7.2=COUNTIFS(A5:AE5,"S8")*8
=SUM(A6:AE6)=COUNTIFS(A6:AE6,"V8")*8+COUNTIFS(A6:AE6,"V4")*4+COUNTIFS(A6:AE6,"V7,2")*7.2=COUNTIFS(A6:AE6,"H7,2")*7.2=COUNTIFS(A6:AE6,"S8")*8
 
Upvote 0
See if this suits you

23 07 09.xlsm
DEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAM
2012345678910111213141516171819202122232425262728293031workedvacationholidaysick
21H7.21177987.58107.5427.510827.58813207.20
22117.587.587.57.58107.578S8S8S8z848V8109.58024
23V4V4V4V8V8V8V7.2V7.2V7.2V8V8V88888117.550.581.600
2488H7.28H7.2H7.285.5781081.55108H7.288111028.80
258H7.2117.56.58448108H7.247.58117.58H7.2H7.26.5127.5028.80
Sum Hours
Cell Formulas
RangeFormula
AJ21:AJ25AJ21=SUM(D21:AH21)
AK21:AM25AK21=SUMPRODUCT(IFERROR((LEFT($D21:$AH21,1)=LEFT(AK$20,1))*MID($D21:$AH21,2,9),0))
 
Upvote 0
Thanks gentlemen, both solutions will do the job. First solution is pretty straight forward and I can comprehend it. The second from Peter; I scratch my head and think what's going on here exactly. I think I'll never master the SUMPRODUCT with all the creative variations. Very slick solution. I'll have to study it to fully comprehend and master it. Nice homework for me. Again, a big thanks to both.
 
Upvote 0
both solutions will do the job.
Does that mean the only possible amount for Sick is 8 hours?
For example, in your sample if instead of vacation 4 hours in cell D24 the person was sick instead of on vacation that cell would say S8 no S4?

Similar with holiday, is the only possibility 7.2 hours?
 
Upvote 0
Does that mean the only possible amount for Sick is 8 hours?
For example, in your sample if instead of vacation 4 hours in cell D24 the person was sick instead of on vacation that cell would say S8 no S4?

Similar with holiday, is the only possibility 7.2 hours?
- First, the numbers represent the amount of hours per day. Numbers without a leading string character are the actual working hours that day.
- When an employee has vacation that day we write V8 meaning 8 hours vacation on that day. This can vary when an emplee has a parttime contract. We than can write V4.
- Then about 7,2. In a normal situation somebody works 36 hours a week. When you divide that by 5 (5 working days per week) you get 7,2.
- When an employee is absent due to illness we use the actual amount of hours that person would have worked on that day. For example when he should have worked 8 hours we change that to S8.

Then the answers to your questions.
No, the amount for sick hours depend on what was the actual working hours on that day.
The same is with your question about vacation. If vacation would be V4 but the employee is absent due to illness we record S4.
Last, holiday depends on the contract the employee has and then divides by 5 like I explained above. 36/5 = 7,2 When the contract is 20 hours it's 20/5 = 4.

Your solution is more robust because it automaticaly takes care of all these different situations. Rajendradk has hard-coded the numbers with the leading string character. So I have to adjust his formula when somebody takes 6 hours vacation on a certain day.
 
Upvote 0
When an employee has vacation that day we write V8 meaning 8 hours vacation on that day. This can vary when an emplee has a parttime contract. We than can write V4.
.. or V6 (or possibly other too)
.. when somebody takes 6 hours vacation on a certain day.
I suspected that other amounts would be possible which is why I questioned your comment that "both solutions will do the job" :)
Anyway, looks like you worked out why I was asking. (y)
Your solution .... automaticaly takes care of all these different situations.
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,115
Members
453,021
Latest member
Justyna P

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