Hello All-
I'm trying to figure out a way to pull the numbers out of a cell and total them up using ( ) to identify when the numbers occur. The cell contains something like this:
asdf(2.0); ASDF (3.0); ASDF (7.5);
Any ideas? I'm stuck...
Hello All-
I'm trying to figure out a way to pull the numbers out of a cell and total them up using ( ) to identify when the numbers occur. The cell contains something like this:
asdf(2.0); ASDF (3.0); ASDF (7.5);
Any ideas? I'm stuck...
Are the values that you posted all in the same cell or in multiple cells? If they are in different cells then the below formula should work. You'll have to change the four instances of "A1" to the correct cell reference.
![]()
=MID(A1,FIND("(",A1)+1,FIND(")",A1)-FIND("(",A1)-1)
Thank you for the reply snax.
The values are all in the same cell. The problem I'm having is that I only want the numbers within the ( ) and I need to keep the format of the numbers to be in tenths.
If you can do a text to columns with a semicolon as the delimiter and then use the formula above for each cell. If you can't do that then I believe the only other way to accomplish what you want done is through VBA.
Probably the most versitile way to do this is with a UDF.
This will sum any amount of numbers in brackets.
Use in Excel![]()
Function SumCell(rng As Range) Dim strTemp As String Dim n As Long Dim switch As Boolean For n = 1 To Len(rng) If Not switch Then If Mid(rng, n, 1) = "(" Then strTemp = strTemp & Mid(rng, n, 1) switch = True Else strTemp = strTemp & " " End If Else If Mid(rng, n, 1) = ")" Then strTemp = strTemp & Mid(rng, n, 1) switch = False Else strTemp = strTemp & Mid(rng, n, 1) End If End If Next strTemp = WorksheetFunction.Trim(strTemp) SumCell = Evaluate(Replace(strTemp, " ", "+")) End Function
Formula:
=sumcell(A2)
See this workbook
[EDIT]
Workbook updated to prove your PM examples, seems fine to me ...
Added another UDF just for fun ...![]()
Last edited by Marcol; 12-11-2012 at 02:33 PM.
If you need any more information, please feel free to ask.
However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....
Also
اس کی مدد کرتا ہے اگر
شکریہ کہنے کے لئے سٹار کلک کریں
If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.
This worked great, thanks Marcol!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks