• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Compile error : Array already dimensioned

curious K

New Member
Dim GrpTot(1, 2)
'Col 1 : Amt
'Col 2 : row no for Where to put
'col 3 : Column no for where to put


GrpTot(0, 0) = 4896.00
GrpTot(0, 1) = 5
GrpTot(0, 2) = 2

Sheets("Summary").Cells(GrpTot(0, 2), GrpTot(0, 1)) = GrpTot(0, 0)


ReDim Preserve GrpTot(2 To 2)


GrpTot(0, 0) = 12541.00
GrpTot(0, 1) = 5
GrpTot(0, 2) = 18

Sheets("Summary").Cells(GrpTot(0, 2), GrpTot(0, 1)) = GrpTot(0, 0)



Error occured at ReDim syntax
---------------------------
Microsoft Visual Basic for Applications
---------------------------
Compile error:

Array already dimensioned
---------------------------
OK Help
---------------------------
__________________________________________________________________
Mod edit : post moved to appropriate forum …
 
Notice : with posting in proper forum,
you must edit your post and use CODE tags ‼​

Your bad : variable is first fixed declared in two dimensions
so you can't preserve & redim it within a single dimension
as explained in VBA help !

Just use a single dimension variable, no need to redim it …

And you even do not need this variable type for this kind of stuff !
 
Sorry for this question,
I'm new to VBA

after
Code:
Dim GrpTot() As Variant

ReDim GrpTot(1,2)
Problem is solved

To define a dynamic array, don't Dim it with a size: like Dim GrpTot(1,2) only create with GrpTot() it will create Dynamic array.
 
Back
Top