x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 307

# 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
0
Blue Street Tech
• 4
• 3
• 2
1 Solution

Commented:
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
0

Commented:
Of course if you want a very simple way then it would be easier to use a custom format in A1:A4, i.e. custom format as

0"h"

and for minutes column 0"m"

Now if you put numbers in those columns they'll display as 34h, for example, if you enter 34....but because the cells ionly contain numbers you can use simple SUM functions

regards, barry
0

Commented:
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
0

Commented:
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
0

Commented:
Yes, Barry is right. INT is correct.

I made my suggestion before seeing any of the other responses.
0

Last KnightAuthor Commented:
@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.
0

Last KnightAuthor Commented:
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
0

Commented:
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
0

Last KnightAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.