Canada Flag

Back

In your worksheet select (from the top menu) Tools|Macro|Visual Basic Editor. On the left, you will see a window titled "Project". Select your spreadsheet (for example, my spreadsheet is called Book 1, look for VBAProject (Book 1)). Then, from the top menu, select Insert|Module. On the right window you will have a blank window representing the new module you just created. Now paste the following code:

Function Numerology(Number As Variant)
'Written by Barrie Davidson
Dim Length As Double
Dim Holder As Double
Application.Volatile
On Error Resume Next
If IsNumeric(Number) = False Then
    Numerology = "N/A"
    Exit Function
ElseIf Number = "" Then
    Numerology = "N/A"
    Exit Function
Else
Evaluation:
    Length = Len(CStr(Number))
    Holder = 0
    For i = 1 To Length
        Holder = Holder + CDbl(Mid(CStr(Number), i, 1))
    Next i
    If Len(CStr(Holder)) > 1 Then
        Number = Holder
        GoTo Evaluation
    End If
End If
Numerology = Holder
End Function

After you have pasted the code, you can close the visual basic editor window (this doesn't take you out of Excel). To access this custom function, (from the top menu in Excel), select Insert|Function. The Paste Function menu box will pop up. Select User Defined in the left window and then select the function you created from the right window.

Copyright © 2001 by Barrie R. Davidson
Added September, 2002