Search This Blog

Friday, 3 August 2012

SUM ALL DIGITS OF A CELL USING VBA

video

Paste the below UDF(User Defined Function) in module and use function.
Function Name  "=sum_cell_values"

Function sum_cell_values(rng As Range)
Dim i As Integer
j = 0
For i = 1 To Len(rng)
j = WorksheetFunction.Sum(j, VBA.Mid(rng, i, 1))
Next
sum_cell_values = j
End Function

Did it help you? Please post your valuable comment. Thanks!

1 comment:

  1. Hi Shweta
    I am just beginning to learn VBA. Could you kindly help me understand the above code bit by bit?
    Regards
    AK

    ReplyDelete