DavetheScot58
New Member
- Joined
- Sep 29, 2017
- Messages
- 2
I am trying to move a row from one worksheet (Active opportunities) to a second worksheet (Archived opportunities) based on whether date(s) entered in column I are up to and including today's date. These dates in column I are forecast archival dates entered in the original worksheet sometimes months in advance. I need the VBA to move the row entry when these archive dates are reached, also, if I don't access the workbook for any period of time, a number of dates may have expired so I need the VBA to check all archived dates up to and including today's date, move the row entries to the archived worksheet and delete the now empty row(s) on the original worksheet. I have entered this in ThisWorkbook so that it starts whenever I open the workbook containing the two worksheets.
As a non-VBA practitioner, I have tried to create this VBA code based on others postings but find that it does not search column I for dates up to and including today's date. Any help would be greatly appreciated.
Private Sub Workbook_Open()
Dim Check As Range, r As Long, lastrow2 As Long, lastrow As Long
Application.ScreenUpdating = False
lastrow = Worksheets("Active Opportunities").UsedRange.Rows.Count
lastrow2 = Worksheets("Filed Opportunities").UsedRange.Rows.Count
If lastrow2 = 1 Then lastrow2 = 0
For r = lastrow To 2 Step -1
If Range("I" & r).Value <= Date Then
Rows(r).Cut Destination:=Worksheets("Filed Opportunities").Range("A" & lastrow2 + 1)
lastrow2 = lastrow2 + 1
Else:
End If
Next r
Application.ScreenUpdating = True
End Sub
As a non-VBA practitioner, I have tried to create this VBA code based on others postings but find that it does not search column I for dates up to and including today's date. Any help would be greatly appreciated.
Private Sub Workbook_Open()
Dim Check As Range, r As Long, lastrow2 As Long, lastrow As Long
Application.ScreenUpdating = False
lastrow = Worksheets("Active Opportunities").UsedRange.Rows.Count
lastrow2 = Worksheets("Filed Opportunities").UsedRange.Rows.Count
If lastrow2 = 1 Then lastrow2 = 0
For r = lastrow To 2 Step -1
If Range("I" & r).Value <= Date Then
Rows(r).Cut Destination:=Worksheets("Filed Opportunities").Range("A" & lastrow2 + 1)
lastrow2 = lastrow2 + 1
Else:
End If
Next r
Application.ScreenUpdating = True
End Sub