Does your data have to be in that form, or could you put it in a table like this:
A1 = "cat"
B1 = "5"
A2 = "dog"
B2 = "8"
Reason I ask is that getting the info you want at that point will be VERY easy. Trying to do what you're asking is going to be difficult.