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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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,215,872
Messages
6,127,437
Members
449,382
Latest member
DonnaRisso

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