Adding comma seperated values within a single cell

M

Michael Toal

I need to come up with a custom function that will add up comma seperated
numerals contained within a single cell.

For example if the the cell A1 contains:

4,5,3

I want the result of the fuction (say in a2) to display the result of 12

Any help greatly appreciated.
Regards
Mike
 
R

Ron Rosenfeld

I need to come up with a custom function that will add up comma seperated
numerals contained within a single cell.

For example if the the cell A1 contains:

4,5,3

I want the result of the fuction (say in a2) to display the result of 12

Any help greatly appreciated.
Regards
Mike


Function AddCSN(str As String) As Double
AddCSN = Evaluate(Application.WorksheetFunction.Substitute( _
str, ",", "+"))
End Function

--ron
 
R

Ron Rosenfeld

I need to come up with a custom function that will add up comma seperated
numerals contained within a single cell.

For example if the the cell A1 contains:

4,5,3

I want the result of the fuction (say in a2) to display the result of 12

Any help greatly appreciated.
Regards
Mike

The following is more efficient than my first (forgot the Replace VBA function)

===========================
Function AddCSN(str As String) As Double
AddCSN = Evaluate(Replace(str, ",", "+"))
End Function
===============================
--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top