We present a transfer matrix method which is particularly useful for solving some classes of sandpile models. The method is then used to solve the deterministic nonabelian sandpile models for N = 2 and N = 3. The possibility of generalization to arbitrary N is discussed briefly.