Redim and dynamic array

fredrerik84

Active Member
Joined
Feb 26, 2017
Messages
383
Hi guys im trying to set my entire worksheet into an array , loop trough the rows/columns and set this data into 2nd array vResult if the date is not over. then the plan is to delete the cells with the first arr and insert the 2nd

Here is what I got, but Im having some problem with the Vresult variant ::/

Rich (BB code):
Sub RemovePassedDate()
Dim Lrow, i, j, k, c  As Long
Dim str As String
Dim Vdata, vResult As Variant
Dim sheet As Worksheet
Set sheet = ActiveWorkbook.Sheets("Matches")
Lrow = sheet.Cells(Rows.Count, "B").End(xlUp).Row




j = 1
   Vdata = sheet.Range("A12:Z" & Lrow)
   For i = LBound(Vdata, 1) To UBound(Vdata, 1)
     If Vdata(i, 1) > Now Then
        For c = 1 To UBound(Vdata, 2)
           ReDim Preserve vResult(j To UBound(vResult) + 1) As String
           vResult(j, c) = Vdata(i, c)
        Next c
     End If
      j = j + 1
   Next i
Set Vdata = Nothing
End Sub

im stuck not able to set the vResult , any help with this would be great..
 
Last edited by a moderator:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
If you use Preserve you can only change the upper boundary of the last dimension of the array. You are trying to change the lower boundary, which is why you get an error. I'm not really sure why you are doing that though.
 
Upvote 0
thanks for your reply.
If you use Preserve you can only change the upper boundary of the last dimension of the array. You are trying to change the lower boundary, which is why you get an error. I'm not really sure why you are doing that though.

- well I dont know what im doing , lol

I want to add entire rows to new array , but not sure how to do do.
then I would want to delete this range Range("A12:Z" & Lrow)
and insert the range from vResults

Just thought I should show what I have done so its easier to see what the problem is
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top