!.......Below Code to
Create User Defined Functions in Excel........!
Use:- To extract numbers & then sum of the values.....
Function EXTRACT_NUMBERS_and_Sum(x) As Variant
Dim c As Variant
c = 0
For i = 1 To Len(Replace(x, " ", ""))
If IsNumeric(Mid(x, i, 1)) = True Then
c = c + Mid(x, i, 1)
End If
Next
EXTRACT_NUMBERS_and_Sum = c
End Function
______________________________________________
Example:-
= EXTRACT_NUMBERS_and_Sum("^&&5**111CDFG8899B$$$$$_~%^*")
Result--------------> 42
Dim c As Variant
c = 0
For i = 1 To Len(Replace(x, " ", ""))
If IsNumeric(Mid(x, i, 1)) = True Then
c = c + Mid(x, i, 1)
End If
Next
EXTRACT_NUMBERS_and_Sum = c
End Function
= EXTRACT_NUMBERS_and_Sum("^&&5**111CDFG8899B$$$$$_~%^*")
Result--------------> 42
No comments:
Post a Comment