Excellll has provided a good formula for this. Here is a VBA function that will do the same. You would call it like this:
=CountR(A2:D4) 'in your example becomes 72
code:
Function CountR(ByVal cell_range As Range) As Long Dim i As Long, j As Long, total As Long Dim varray As Variant varray = cell_range.Value For i = 1 To UBound(varray, 1) For j = 1 To UBound(varray, 2) If Right$(varray(i, j), 1) = "R" Then total = total + Left$(varray(i, j), Len(varray(i, j)) - 1) End If Next Next CountR = total End Function
source share