I am trying to copy values from one array into a new one, however I don't know how many columns or rows are going to be needed for the new array.
I have tried to ReDim the array but it does work. Can anyone tell me what's wrong with the code.
Thanks
numrows=ubound(arrRecords,2)
numcols=ubound(arrRecords,1)
prevrep=arrRecords(0,0)
Dim arrNrec()
ReDim arrNrec(2,2)
arrNrec(0,0)=arrRecords(0,0)
For rowcounter = 0 To numrows
If prevrep <> arrRecords(0,rowcounter) Then
prevrep=arrRecords(0,rowcounter)
ncol=1
If nrow >= UBound(arrNrec,2) Then
ReDim Preserve arrNrec(ncol,nrow + 5)
End If
nrow = nrow + 1
arrNrec(0,nrow)=arrRecords(0,rowcounter)
End If
arrNrec(ncol,nrow)=arrRecords(1,rowcounter)
If ncol >= ubound(arrNrec,1) Then
ReDim Preserve arrNrec(ncol + 2,nrow)
End If
ncol=ncol+1
Next
I have tried to ReDim the array but it does work. Can anyone tell me what's wrong with the code.
Thanks
numrows=ubound(arrRecords,2)
numcols=ubound(arrRecords,1)
prevrep=arrRecords(0,0)
Dim arrNrec()
ReDim arrNrec(2,2)
arrNrec(0,0)=arrRecords(0,0)
For rowcounter = 0 To numrows
If prevrep <> arrRecords(0,rowcounter) Then
prevrep=arrRecords(0,rowcounter)
ncol=1
If nrow >= UBound(arrNrec,2) Then
ReDim Preserve arrNrec(ncol,nrow + 5)
End If
nrow = nrow + 1
arrNrec(0,nrow)=arrRecords(0,rowcounter)
End If
arrNrec(ncol,nrow)=arrRecords(1,rowcounter)
If ncol >= ubound(arrNrec,1) Then
ReDim Preserve arrNrec(ncol + 2,nrow)
End If
ncol=ncol+1
Next