Welcome Guest
( Log In | Register )
The time is now 11:37 pm
You last visited January 20, 2017, 11:12 pm
All times shown are
Eastern Time (GMT-5:00)

Sum of Digits in 1 Cell - VBA Code

Published:

  • 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 number.
  • Click OK.
  • Good for Pick 3 and Pick 4 digit numbers or any size number (I think)
Entry #25

Comments

This Blog entry currently has no comments.

You must be a Lottery Post member to post comments to a Blog.

Register for a FREE membership, or if you're already a member please Log In.