If you get a result other than 0 with this formula:

=COUNTIF(expences!$B$2:$B$9997,"*")

That means there are TEXT entries in the date range and those text entries will cause your orgiinal formula to return the #VALUE! error.

Do you have a backup copy of the file? That's the only way to go back to a previously saved version.