I have this code to count the number of letter "R" in any given row, see test file below, these two rows contain 2x "R"
but my code is spitting out 3 every time... why is that?
code below:
but my code is spitting out 3 every time... why is that?
code below:
VBA Code:
Dim ws1 As Worksheet
Dim lrNew As Long, n As Long, n1 As Long, n2 As Long, sr As Long
Set ws1 = ActiveSheet
lrNew = ws1.Range("K" & Rows.Count).End(xlUp).Row
sr = 2
If ws1.Cells(lrNew, "K").Value Like "*CS55*" Then
n = WorksheetFunction.CountIf(ws1.Range("K" & sr & ":K" & lrNew), "*R*")
End If
MsgBox n