Hi guys Im hoping someone could help me out a little, Ive been working on a huge custom filter which has 3 slight variations but they are all basically the same code
Sub RemovePassedDate()
Dim Lrow, i, j, k, c As Long
Dim str As String
Dim vdata() As Variant
Dim vResult() As Variant
Dim Sheet As Worksheet
Set Sheet = ActiveWorkbook.Sheets("Matches")
Lrow = Sheet.Cells(Rows.Count, "B").End(xlUp).Row
Application.ScreenUpdating = False
vdata = Sheet.Range("A12:Z" & Lrow)
ReDim vResult(UBound(vdata, 1), UBound(vdata, 2))
For i = LBound(vdata, 1) To UBound(vdata, 1)
If vdata(i, 1) > Now Then
For c = 1 To UBound(vdata, 2)
If c > 0 Then vResult(j, c - 1) = vdata(i, c)
Next c
j = j + 1
End If
Next i
Sheet.Range("A12:Z" & Lrow).ClearContents
Sheet.Range("A12:Z" & UBound(vResult, 1)) = vResult
Application.ScreenUpdating = True
End Sub
I thought everything were working fine untill now when Ive tested it a little more.
- Running the macro first time always produce the correct result.
(this subs removes past dates based on values in col B)
But If I am to run this sub for a 2nd time it removes more rows and outside of what I thought were the criteria . I'm not sure whats happening. I thought maybe the Lastrow var or something gets messed up but that's not the case.
i also tried adding this at the end but didnt help
Erase vdata
Erase vResult
Anyone know what might be the problem. Also Obviously I know its necessary to run this macro more then once but I would Like to run a quite similar macro after this one but its not working as I would expect ??
any help would be much appreciated..
frederik
Bookmarks