Extract number of data points from an equation...

Sontauzo

New Member
Joined
Mar 13, 2018
Messages
18
Hello all,

I have an odd inquiry. I have a spreadsheet that contains cells that have multiple data points in them. Most of them look like this 120+120+60+50. This gives me a great total, but I am wondering if there is a way to find out how many entries there are in each cell. For instance, in the example above, I am looking for a marco to return the number '4' since there are 4 entries in the cell. The tricky part is that some of the cells have multiplication formulas also. Example: 120*3+50+30*4. In this example I would want to know that there were '8' entries that made up that total.

Is such a thing even possible? The spreadsheet is large and i was hoping for a faster way of analyzing this information.

Thank you for your time and assistance,

BWL
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Most of them look like this 120+120+60+50. This gives me a great total ...

I am guessing you mean a formula: =120+120+60+50 rather than a string: 120+120+60+50

This should work either way, provided your formulae/strings are always as specified, e.g. no other characters such as brackets?

Code:
Function GetCount(InValue As Variant) As Long

    Dim s As String
    
    s = InValue
    On Error Resume Next
    s = InValue.Formula
    On Error GoTo 0
    
    GetCount = Len(s) - Len(Replace(Replace(s, "+", ""), "*", "")) + 1
    
End Function

I am also guessing that your 8 for the second example was a typo, and should have been 5?
 
Upvote 0

Forum statistics

Threads
1,224,749
Messages
6,180,727
Members
452,995
Latest member
isldboy

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