Tried that, but it gives the wrong value.
In what way is it wrong? Do you want the border values (0, 10, 20, 30, etc ) excluded from the count, or included in the upper count)?
Also, are you sure that you've used a semicolon and not a comma
between the range and the criterion? I.e. =COUNTIF(range;
The COUNTIF function allows only one criterion at a time so I doubt =COUNTIF(A2:A22;">=0"&"<=9") will work.
Here is a file you can download and open with Excel. It should illustrate things a bit better:https://drive.google.com/open?id=0B15XOtoadAdJZVV0OG1MNkFQa2M