Sunday, 9 December 2012

Excel VBA Macro To Sum The Individual Digits of Number

 How To Sum The Individual Digits of Number Excel VBA Macro

'Suppose In Column 'A' having Numbers Then You Can find the Sum of Individual Digits of Numbers in Column 'B'
'Eg: A1=147 then B1=1+4+7=11 will return.

Sub SumDigitz()
Dim i As Integer
Dim j As Integer
For i = 1 To 100 'Rows Having Numbers

Cells(i, 2).Clear
If Cells(i, 1) = "" Then Exit For

For j = 1 To Len(Cells(i, 1))
Cells(i, 2) = Cells(i, 2) + Mid(Cells(i, 1), j, 1)
Next j

Next i
End Sub

Thanks, TAMATAM

No comments:

Post a Comment

Hi User, Thank You for Visiting My Blog. Please Post Your Feedback/Comments/Query.

Subscribe to Blog Posts by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts