Sub OutOfDateSubs()
Dim LastRow As Integer
Dim FirstAddress As String
Dim FirstColumn As Integer
Dim FindLastAddress As String
Dim FindLastColumn As Integer
Dim LastColumn As Integer
Dim NumberColumns As Integer
Dim ActiveRow As Integer
Dim Documents As String
Dim ExpDate As Date
Dim Email As String
Dim EmailColumn As Long
Dim CurrentCell As String
Dim CurrentDate As Date
Dim DaysRemaining As Long
ThisWorkbook.Sheets("Subcontractors").Select
LastRow = Range("A" & Rows.Count).End(xlUp).Row '(So we know where to stop)
'MsgBox LastRow
FirstAddress = Cells.Find(What:="Accreditations").Address 'Find The First Address Of The "Accreditations" Cell
ActiveSheet.Range(FirstAddress).Select
FirstColumn = ActiveCell.Column 'Find The First Address Of The "Accreditations" Cell
ActiveSheet.Range(FirstAddress).Select 'Select First Services Column to get the Column Number
'MsgBox " First Column Of Accreditations " & FirstColumn
FindLastAddress = Cells.Find(What:="Insurance").Address 'Find The First Address Of The "Insurance" Cell
ActiveSheet.Range(FindLastAddress).Select
FindLastColumn = ActiveCell.Column
ActiveSheet.Range(FindLastAddress).Select
ActiveCell.Offset(, 1).Select 'Offset to end of merged row
ActiveCell.Offset(2, -1).Select 'Offset Down 2 Rows and left 1 Column
LastColumn = ActiveCell.Column
'MsgBox "Last Column Of Insurance " & LastColumn
NumberColumns = LastColumn - FirstColumn + 1
ActiveSheet.Range("F4").Select
ActiveRow = ActiveSheet.Range("F4").Row
'MsgBox ActiveRow
For i = 1 To NumberColumns
If ActiveCell = "n/a" Or ActiveCell = "In Progress" Or ActiveCell = "On Request" Then
'Do Nothing
Else
CurrentCell = ActiveCell.Address
CurrentDate = ActiveCell.Value
DaysRemaining = DateDiff("D", Now(), CurrentDate)
'MsgBox DaysRemaining
If DaysRemaining <= Worksheets("Email_Time_Frames").Range("B3") Then
'MsgBox "In 60 Days " & ActiveCell.Address
Email = Cells(ActiveCell.Row, 3).Value
'MsgBox Email
ExpDate = ActiveCell.Value
'MsgBox ExpDate
Documents = Cells(3, ActiveCell.Column).Value
'MsgBox Documents
***** Offset 1 column, Check last sent ********
***** If with GoTo *****
Call EmailOutOfDate(Email, ExpDate, Documents, DaysRemaining)
ActiveCell.Offset(0, 1).Select:
If ActiveCell = "0" Then
'Do Noting
Else
Select Case DaysRemaining 'Mark Next Time Frame Email Needs To Be Sent
Case Is <= ThisWorkbook.Sheets("Email_Time_Frames").Range("E3").Value
ActiveCell.Value = ThisWorkbook.Sheets("Email_Time_Frames").Range("F3").Value 'Reset
Case Is <= ThisWorkbook.Sheets("Email_Time_Frames").Range("D3").Value
ActiveCell.Value = ThisWorkbook.Sheets("Email_Time_Frames").Range("E3").Value 'Cant Schedule
Case Is <= ThisWorkbook.Sheets("Email_Time_Frames").Range("C3").Value
ActiveCell.Value = ThisWorkbook.Sheets("Email_Time_Frames").Range("D3").Value '3rd Email
Case Is <= ThisWorkbook.Sheets("Email_Time_Frames").Range("B3").Value
ActiveCell.Value = ThisWorkbook.Sheets("Email_Time_Frames").Range("C3").Value '2nd Email
End Select
End If
Cells.Range(CurrentCell).Select
End If
End If
ActiveCell.Offset(, 2).Select
If ActiveCell.Column = LastColumn + 1 Then 'Move to Next Row
Cells((ActiveRow + 1), FirstColumn).Select
ActiveRow = ActiveRow + 1
'MsgBox ActiveRow
i = 0 '0=Normal,1=Test 1 row only
End If
If ActiveRow = LastRow + 1 Then
Exit Sub
End If
Next i
Unload Admin1
End Sub