Search code examples
google-sheetscountif

Count if two consecutive cells match a specific criteria


Take this spreadsheet

I am trying to count the number of times blue is followed by green in the range. You can see I tried using the formula

=countif(A1:A20,B1:B2)

This did not work as it should return 3, but is only counting the number of times blue appears. How can i fix this?

Thanks!


Solution

  • You may try:

    =countifs(A1:A19,B1,A2:A20,B2)