How to Calculate the Date and The Number

  • Thread starter Thread starter mroks
  • Start date Start date
M

mroks

Guys,

Please help me on how to do the below calculations.

Date (YYDDMM)
080131 = it goes like this 8+1+3+1 = 13 is the answer
Text
1000888 = it goes like this 1+8+8+8= 25 is the answer


Thanks
 
This function will do what you seek:

Private Function GetSumOfDigits(varData As Variant) As Long
Dim lngPos As Long, lngSum As Long
lngSum = 0
If IsNull(varData) = False Then
For lngPos = 1 To Len(varData)
lngSum = lngSum + Val(Mid(varData, lngPos, 1))
Next lngPos
End If
GetSumOfDigits = lngSum
End Function
 
Back
Top