Link to home
Start Free TrialLog in
Avatar of Blue Street Tech
Blue Street TechFlag for United States of America

asked on

Simplified Excel Formula Needed

I am looking for simplified formulas if available.

Range A1:A4 = Hours; Range B1:B4 = Minutes. I need to sum both ranges so that I get a xx hours and xx minutes. AutoSum does not work because the “h” and “m” that are added to each range making them nonnumeric values. My solution was: =VALUE(IF(LEN(A1)>2,LEFT(A1,2),LEFT(A1,1))) –which simply states IF A1 is has a character count greater than 2 return 2 characters from the left, otherwise return only 1 character from the left and make all results numeric values.

The goal is to sum the minutes column keeping them in standard 60 minute increments and adding the overflow to the sum of the hours. E.g. if the hours column = 1 and the minutes column = 90 the final result would be 2 hours and 30 minutes.

I am using Excel 2010
I attached screenshots of the data & formula view as well as the file (.XLSX).

Any suggestions on how I can simplify these formulas? Thanks!

Excel-Data.JPG
Excel-Formulas.JPG
Excel-Example.xlsx
Avatar of barry houdini
barry houdini
Flag of United Kingdom of Great Britain and Northern Ireland image

You can use SUBSTITUTE to get rid of the "h"s and "m"s, i.e. for A6 to give total hours

=SUMPRODUCT(SUBSTITUTE(A1:A4,"h","")+0)+INT(SUMPRODUCT(SUBSTITUTE(B1:B4,"m","")+0)/60)

and in B6 for total remaining minutes

=MOD(SUMPRODUCT(SUBSTITUTE(B1:B4,"m","")+0),60)

see attached

regards, barry
27344329.xlsx
ASKER CERTIFIED SOLUTION
Avatar of barry houdini
barry houdini
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A better way to do it than text manipulation would be to set a custom number format to display the "h" and "m" in a way that allows Excel to understand the values as numbers and sum them normally. See attached for your example with the custom formatting.

For hours, I used this:
##"h";;0"h"

For minutes, I used this:
###"m";;0"m"

Then all you need are regular numeric functions.
For hours, take  the minutes subtotal divided by 60 and rounded to a whole number of hours and add it to the hours subtotal. For minutes, use the MOD function to return the remainder of minutes left over when you take the whole hours out. Excel-Example.xlsx
Hello telyni19,

That's similar to my second suggestion but I don't think you should be using ROUND because that will round to the nearest hour when it should always be rounded down, e.g. if you change the minutes in B2 to 6 instead of 43 then the total should go down by 37 minutes and become 13 hours 35 mins ....but with ROUND the hours are 14....you should use INT in place of ROUND, i.e. in A7

=A6+INT(B6/60)

regards, barry
Yes, Barry is right. INT is correct.

I made my suggestion before seeing any of the other responses.
Avatar of Blue Street Tech

ASKER

@ALL: Wow my formulas were ridiculous in comparison. Hahaha Thank you both for your quick responses!

@barryhoudini: I am awarding points for your second post as this is the simplest & most accurate formula. Thanks again.
FYI: For future members; because the live data is spread out throughout the worksheet I am using the following formulas for Hours & Minutes respectively based on barryhoudini solutions (http:#a36712359 and consolidating it in http:#a36712378):

=SUM(A1,A2,A3,A4,INT(B6/60)) for hours

=MOD(SUM(B1,B2,B3,B4),60) for minutes
Note that you don't have to separate out the cells in the SUM function, you can use

=SUM(A1:A4,INT(B6/60))

and

=MOD(SUM(B1:B4,60)

regards, barry
Yes, I know…it was a poor example on my part...the example that I posted here is much different from the actual worksheet. In the actual worksheet the cells are randomly placed that need to be tallied - the range is non-existent there.