1

I have a Range array declared

Dim aRange(1 to 5) as Range

I am unable to resize the array later on in my code using

ReDim Preserve aRange(1 to a)

Is there something I am doing wrong or am I unable to resize a Range array.

1 Answer 1

3

Change:

Dim aRange(1 to 5) as Range 'Static dimensioning, cannot be changed later on

by:

Dim aRange() as Range 'Declared as dynamic array, have to be redim before using it

So:

Dim a as Integer
a = 6    

Dim aRange() as Range 'Declared as dynamic array, have to be redim before using it

ReDim Preserve aRange(1 to 5)
ReDim Preserve aRange(1 to a)

See ReDim Statement

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.