Google Exceltip.com
Account Icon
Shopping Cart
CheckOut

» 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: 26702
      No comments have been submitted.


    REGISTERED USERS click here to post comments


    GUESTSclick here to Register
    Name
    Comment Title
    Comments


    Terms and Conditions of use
    The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

    Copyright © 2003 ExcelTip.com
    Microsoft, Microsoft Excel is a U.S. registered trademark of Microsoft Corporation