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.

Post a Comment

Please Log In

To use this feature you must be logged into your Lottery Post account.

Not a member yet?

If you don't yet have a Lottery Post account, it's simple and free to create one! Just tap the Register button and after a quick process you'll be part of our lottery community.

Register