Are you talking about the last formula? It should work with any number of frames in the animation.
I am not very good at explaining..
Here "8" means sensitivity - frame will change every 8 pixels.
%Sprite4.AnimationFrameCount is the remainder after division. For example, 50%36 will give you frame number 14 in animation with 36 frames.
(Sprite4.AnimationFrameCount*10) - this part of the formula is needed to prevent the value in brackets to go into negative numbers (when you swipe to the left). It basically just adds 360. For example: