I want to create a function called MAXCONS that counts the maximum consequent occurrences of a specified value within given range. E.g.

If A1=“X”, A2=“X”, A3=“Z”, A4=“X”, A5=“Z”, A6=“Z”, A7=“Z”,

then MAXCONS(A1:A7, “X”) should return 2, because the value “X” appeared maximum 2 consequent times. And MAXCONS(A1:A7, “Z”) should return 3.

My questions:

- Where can I learn how to do this?
- Can I do this in Javascript? If yes, how?
- Can you provide a sample/dummy function definition (without implementing the above logic), to which I can add the function body and use the function within a calc document?

Thank you!