A method for counting steps and an electronic apparatus are provided. The method includes the following steps: obtaining first three-axis accelerating values of the electronic apparatus removing a specific ratio of an acceleration of gravity from the first three-axis accelerating values to generate second three-axis accelerating values calculating inner product values and outer produce values according to the second three-axis accelerating values determining whether a user of the electronic apparatus is in a walking status if yes, setting the inner product values as reference values if no, setting the outer product values as the reference values calculating a number of steps corresponding to the second three-axis accelerating values according to the reference values.