Sunday, December 9, 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 genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog