How to Sum the Individual Digits of Number using 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
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
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.