Sum part of cell if cell contains certain text

Lunatic90

New Member
Joined
Nov 28, 2015
Messages
4
Hello,

I have a question:

In a file i have a table with names (column A) and dates (row 1).
In the table i keep track of the holiday requests of my employees.
I do that by noting down the type (A or V) and the number of hours they request in one cell.
The number of hours can be any value between 0 and 8.
For Example, i have V8 for 8 hours of 'verlof'.

Now, i'm wondering if there is a formula that can sum the number of hours within a certain time period (changeable) if the cell starts with V or with A.

See the link for an example picture:
https://imgur.com/kcU8AuZ

In short: i need formulas in the yellow cells that automatically give the same results as i manually calculated.

Is this possible?

Thanks in advance!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
11-72-73-74-75-76-77-78-79-710-711-712-713-714-715-716-717-718-719-720-721-722-723-724-725-726-727-7Sum VSum A
2WilliamV8V8A4A4V8A41612
3DmitriV5.2V6.4V8V8V6.427.60
4LindaA4A4V8V8V804
5SandraV8V8V8V8V8240
6
7Start Date05/07/2018
8End Date20/07/2018
Sheet1
Cell Formulas
RangeFormula
AC2=SUMPRODUCT(($B$1:$AB$1>=$F$7)*($B$1:$AB$1<=$F$8)*(LEFT($B2:$AB2,1)=RIGHT(AC$1,1)),("0"&MID($B2:$AB2,2,8))+0)
AD2=SUMPRODUCT(($B$1:$AB$1>=$F$7)*($B$1:$AB$1<=$F$8)*(LEFT($B2:$AB2,1)=RIGHT(AD$1,1)),("0"&MID($B2:$AB2,2,8))+0)


WBD
 
Upvote 0
I think i understand most of the formula, but translating it to my Dutch Excel formulas doesn't seem to work.
I also tried entering it as a Matrix Formula with ctrl+shift+enter, since it looks like this is necessary.

Do you mind explaining the following piece of code?:
I don't really get this part...

Code:
[COLOR=Blue]([COLOR=Red]"0"&MID([COLOR=Green]$B2:$AB2,2,8[/COLOR])[/COLOR])+0[/COLOR]

And I use Excel 2013, in case that may cause a problem...
 
Upvote 0
It doesn't need Ctrl+Shift+Enter as it's not an array formula. In Dutch my guess is it would be:

Code:
=SUMPRODUCT(($B$1:$AB$1>=$F$7)*($B$1:$AB$1<=$F$8)*(LEFT($B2:$AB2,1)="V");("0"&MID($B2:$AB2,2,8))+0)

This piece:

Code:
("0"&MID($B2:$AB2,2,8))+0

Converts each line to an array of numbers. You can use the Evaluate Formula button to step through and see where it's failing.

WBD
 
Upvote 0
Oh, i'm sorry!
I made an error with the location of brackets near the +0 at the end...

Your formula works like a charm! Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,757
Messages
6,126,693
Members
449,331
Latest member
smckenzie2016

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