0

I typically consider myself a super-user for excel-vba related things. However, this one has me stumped.

I have a line of code returning 'runtime-9, subscript out of range', but it appears that the subscript is not out of range.

When the following code is evaluated, it returns the subscript error.

Range(Cells(RowArray(j, 0), coLs(colSetNum, i)), Cells(RowArray(j, 1), coLs(colSetNum, i))).Select

Where RowArray(j,0)=2, colSetNum=0, i=0, and RowArray(j,1)=6. (all values from the mouse-over text).

I checked the locals window, and coLs(0)(0)=2, so it shouldn't be returning this error.

Any suggestions?

7
  • so is coLs an array of arrays or is it a two dimensional array, you show it both ways. Maybe you should use coLs(colSetNum)(i) Commented May 29, 2018 at 15:14
  • coLs is an array of arrays. Do I have to reference that as (0)(0) rather than (0,0)? Commented May 29, 2018 at 15:26
  • Yes, and also one should avoid using .Select. It slows down the code. Commented May 29, 2018 at 15:27
  • Ah, that did it! my next line is selection.copy. I tried just doing Range().copy, but it didn't seem to like that. What alternatives are there? Commented May 29, 2018 at 15:35
  • there are many. it also depends on how you are pasting the copy. But that is a new question. Commented May 29, 2018 at 15:39

1 Answer 1

1

Arrays of Arrays have to be referenced as arr(x)(y), rather than arr(x,y).

Fixing this fixed the program.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.