Adding Numbers in a Cell

kwedde01

Board Regular
Joined
Jun 9, 2005
Messages
140
How can I add several numbers in a cell.

For example: Cell A1 would contain the numbers 5,10,6,12,etc.

Each comma represents the end of a number and the start of a new one. How would I then add these 4 numbers in the same cell.
 
kwedde01 said:
I get an error message of #NAME when i try the Test function.

I try entering 2,3 in cell A1 on a new sheet, and I place the formula in cell b1 but get that error messages

Any suggestions

Yu have to copy the function above to a standard module [ module1, etc ] in your workbook in order for it to work.
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
How can I modify the code so that it will also, read cells with only one entry and no comma, or count cells with no entry as 0.
 
Upvote 0
<font face=Courier New><SPAN style="color:#00007F">Function</SPAN> Test(Rng <SPAN style="color:#00007F">As</SPAN> Range) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Variant</SPAN>
    <SPAN style="color:#00007F">If</SPAN> Rng.Cells.Count > 1 <SPAN style="color:#00007F">Then</SPAN>
        Test = "Error: single cell ref only"
        <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Function</SPAN>
    <SPAN style="color:#00007F">ElseIf</SPAN> Len(Rng) = 0 <SPAN style="color:#00007F">Then</SPAN>
        Test = vbNullString
        <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Function</SPAN>
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
    Test = Evaluate(Application.Substitute(Rng, ",", "+"))
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Function</SPAN></FONT>
 
Upvote 0

Forum statistics

Threads
1,215,528
Messages
6,125,342
Members
449,218
Latest member
Excel Master

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