Strip/Grep numbers and not letters

shdawson

Active Member
Joined
Jan 6, 2007
Messages
381
Hi,


I have a column that is a listing of scheduled work. Unit-of-measure is hours. Examples of this include:
0.25h
3.00h
3h
2,450h


What I need to do is total these numbers, based upon other colums that show department and what not. I can SUMPRODUCT that part, no problem.

It seems like dropping the "h" and converting to a number is the way to go. It would be oh-so-nice to do this in a formula.

So, to that end....is there a formula combo that can do this, please? Or, is it easier to break into 2 actions. 1 formula to strip the "h", and then another to do the sum-ing part?


Thanks,
SHD
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
You might try

=LEFT(A1,LEN(A1)-1)+0


That could probably be included in your sumproduct...
 
Upvote 0
OK, that formula will work for now. I will mess wtih it a bit and see about integrating into 1 formula or going with 2 actions of stripping the "h" then summing.

Thank you very much.


Kindly,
SHD
 
Upvote 0
It doesn't actually need it..

The Left function returns a TEXT string.
If you try to reference it with another formula, it won't be considered a real number.
Adding the +0 converts the text string into a real number
 
Upvote 0
In one formula:

=SUMPRODUCT(--(SUBSTITUTE(A1:A4,"h","")))

Excel Workbook
ABC
10.25h2456.25
23.00h
33h
42,450h
Sheet1
 
Upvote 0
Wow, now that is trivia. Converting to a number with +0, way cool!
The "general rule" is if you involve a text string that looks like a number in a mathematical operation, Excel will convert the text string to its numerical value in order to be able to complete the mathematical operation. Adding 0 to your text string involves it in a mathematical operation and the addition of 0 is used so the overall calculation will not change the text string's numerical value once the conversion has occurred. Two other "standard" ways of doing this would be...

=1*LEFT(A1,LEN(A1)-1)

=--LEFT(A1,LEN(A1)-1)

where the double minus sign is the equivalent of multiplying by minus one twice (-1 * -1 = +1).
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,903
Members
452,948
Latest member
Dupuhini

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