It's actually more complicated:
1) So now my working workbook (5days lookahead) and my data workbook (Airframe Daily with date variable) are opened.
2) I want to go to Daily, tab Tier 2 to find out how many rows of data I have.
3) Then for anything with 3rd column with a date less than now() =7, I want to copy that row
4) Then go to the 5 days workbook, Tier 2 tab, and paste that row to the row after the last record.
Dim i As Integer
Dim iLastRowT2 As Integer
Dim i5DLastRowT2 As Integer
' Find Last Row of Data in Tab Tier 2 90 Day Look Aheads
Windows(strTodayFileName).Activate
Sheets("Tier 2 90 Day Look Aheads").Select
With ActiveSheet
If Application.WorksheetFunction.CountA(.Cells) <> 0 Then
iLastRowT2 = Cells.Find(What:="*", _
After:=.Cells(1, 1), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
Else
iLastRowT2 = 1
Cells(iLastRowT2, 1).Select
Exit Sub
End If
End With
Cells(iLastRowT2, 1).Select
ActiveCell.Offset(1, 0).Activate
'Find any row with Due date within 7 days
For i = 2 To iLastRowT2
If Cells(i, 3) < Now() + 7 Then
Rows(i).Copy
Windows("5Days Lookahead Template.xlsm").Sheets("Tier 2").Select
With ActiveSheet
If Application.WorksheetFunction.CountA(.Cells) <> 0 Then
i5DLastRowT2 = Cells.Find(What:="*", _
After:=.Cells(1, 1), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
Else
i5DLastRowT2 = 1
Cells(i5DLastRowT2, 1).Select
Exit Sub
End If
End With
Cells(i5DLastRowT2, 1).Select
ActiveCell.Offset(1, 0).PasteSpecial
End If
Next i
Bookmarks