Home > Software engineering >  EXCEL VBA array subscript crossing the line
EXCEL VBA array subscript crossing the line

Time:11-16

Why always tip line 8 subscript crossing the line? Not crossing the line, also define the dimension of the array,



Sub array every other line extraction into a new array ()
Dim Arr, K, I
Arr=Worksheets (" sheet2 "). The Range (" a1: f10 ")
ReDim Brr (5, 6)
K=1
For I=LBound (Arr) To UBound (Arr) Step 2
For J=LBound (Arr, 2) To UBound (Arr, 2)
Brr (K, J)=Arr (I, J) : K=K + 1
Next
Next
Worksheets (" sheet3 "). The Range (" a1 "). The Resize (5, 6)=Brr
End Sub

CodePudding user response:

K=k + 1 should be take out from the first layer in the loop

CodePudding user response:

Has solved the ! .

CodePudding user response:

To solve the good,

CodePudding user response:

Array I also often encountered this kind of problem that the subscript bounds, are minor issues, however, a careful analysis can be found,

CodePudding user response:

The breakpoint is when things go wrong, and then see which subscript crossing the line
The next step is checking logic, the definition of what is an array collection wrong or subscript calculation errors,
  •  Tags:  
  • VBA
  • Related