|  

» Sum the digits numbers in a cell using custom VBA function in Microsoft Excel

  • Alt+F11 to open Visual Basic Editor (VBE).
  • From the Insert menu, select Module (to add a module).
  • Enter the following lines of code into the module:

  •  Function SumDigits(Number)
        Dim i As Integer
        For i = 1 To Len(Number)   
          SumDigits = SumDigits + Val(Mid(Number, i, 1))
        Next i
     End Function

    To test the function:

  • To test the function, open Paste Function (Shift+F3).
  • From the User Defined category, select the SumDigits function.
  • In the function box, select any cell that contains a date.
  • Click OK.


  • Rate This Tip
    12 34 5
    Rating: 3.68     Views: 29122
    No comments have been submitted.
    Click here to post comment
    For Registered Users
    Name
    Comment Title
    Comments