I'd like to bet that it's a non invertable matrix because, for example
if E12 contains the value 3, the matrix 'temprate' you're trying to
invert is 4 x 4 with zeroes all along the bottom and right hand side.
(Changing the bottom right member from 0 to 1 changed the error to
'Type mismatch', and worked on the sheet too.)
Try setting
Option Base 1
or ReDim temprate(q-1,q-1)
(along with the other arrays)
I didn't solve the type mismatch though, but you should be one step
further..