So I mean something like this:
if(counter value)>=
{
//do something
}if(value<limit)//value is the number on your counter, limit you have to replace by the number, when it should stop
{
countUp();
//or
value++;
//however you count up
}