You are creating variables without defining what type of data they are. If you define their types, you will be able to more easily spot the errors in your code. Looking at the first time the variables are assigned values, I would deduce the following types.
Dim i as Integer, j as Integer, p as Integer, q as Row
However, you then test q as if it is a number. I expect that would cause the Run-time error you encountered.
Then with the variable arr, you populate it as a Range and then use UBound on it as if it is an array. This might work in Excel's vba but I would not be surprised if it didn't.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
|