PDA

View Full Version : Solved: Sum 'A' if there's any digit into string in 'B'



omp001
05-01-2012, 08:27 AM
Hi all.

.A......... B
10.....123 ab
20.....123ab
30.....ab 123
40.....ab123
50.....123
60.....ab

I need to sum values from column 'A' if same row in 'B' there's some digit.
So, in e.g. above the result would be 10+20+30+40+50=150

Thanks in advance.

nilem
05-01-2012, 09:14 AM
UDF
Function NumStr#(rSum As Range, rCheck As Range)
Dim i&, smm#
If rSum.Count <> rCheck.Count Then Exit Function
For i = 1 To rSum.Count
If rCheck(i, 1) Like "*[0-9]*" Then smm = smm + rSum(i, 1)
Next i
NumStr = smm
End Function

omp001
05-01-2012, 12:28 PM
Hi nilem.
Works nicely.
Thanks for your attention and for your time.