Excel: Counting the number of cells with two digits

I cannot for the life of me figure out why I am getting a mismatch in the following code. I'm trying to have it just count the number of cells in a range with two digits. I highlighted the spot where I'm getting a mismatch error:

lastrow = foswork.Cells(foswork.Rows.Count, 2).End(xlUp).row
    For x = 1 To 5
        Set rng = foswork.Range(foswork.Cells(1, x + 5), foswork.Cells(lastrow, x + 5))
        staffing.Cells(x + 4, (3 * i) - 1) = _
            Application.WorksheetFunction.SumProduct(--(Len(rng) = 2)) - _
            Application.WorksheetFunction.CountIfs(rng, "SB")
    Next x
Thanks in advance for the help!

This question generated 12 answers. To proceed to the answers, click here.

This thread is current as of December 17, 2014.

For more resources for Microsoft Excel