>>672
>Dim i, j, k, l, m, n, o, p As Integer 'ループ用カウンタ

これでは、i-oまでは全て Variantだ。
pしか integer宣言されていないぞ。
面倒でも、全部に As Integerを書くべし。