Public Sub leem2()
Dim i, j, k, y, z As Integer
Dim FNextrow As Long
Dim MNextrow As Long
Dim LNextrow As Long
Dim SQtr As Date
Dim EQtr As Date
Dim lngDR As Long
Dim blnBlank As Boolean
Sheets("Completed").Activate
SQtr = CDate(InputBox("Please enter the first date of the current quarter"))
EQtr = CDate(InputBox("Please enter the final date of the current quarter"))
With Sheets("ACE")
For i = 3 To .Cells(3, 1).End(xlDown).Row
'Checks if ACE tab, column F=16. If true, transfer to Completed sheet.
FNextrow = Sheets("Completed").Cells(Rows.Count, 1).End(xlUp).Row + 1
If .Cells(i, 6).Value = 16 Then
Sheets("Completed").Range(Cells(FNextrow, 1), Cells(FNextrow, 5)).Value = .Range(.Cells(i, 1), .Cells(i, 5)).Value
End If
'Checks if ACE tab, column E=PS or E=TS, with other conditions listed below.
MNextrow = Sheets("Completed").Cells(Rows.Count, 7).End(xlUp).Row + 1
blnBlank = False
Select Case .Cells(i, 5).Value
Case "PS"
For z = 7 To 37 Step 2
If .Cells(i, z).Value = 0 Then blnBlank = True
Next z
If blnBlank = False Then
Sheets("Completed").Range(Cells(MNextrow, 7), Cells(MNextrow, 11)).Value = .Range(.Cells(i, 1), .Cells(i, 5)).Value
End If
Case "TS"
For y = 7 To 37 Step 2
If y <> 17 And y <> 19 And y <> 21 And y <> 33 And y <> 35 Then
If .Cells(i, y).Value = 0 Then blnBlank = True
End If
Next y
If blnBlank = False Then
Sheets("Completed").Range(Cells(MNextrow, 7), Cells(MNextrow, 11)).Value = .Range(.Cells(i, 1), .Cells(i, 5)).Value
End If
End Select
lngDR = .Cells(Rows.Count, "AL").End(xlUp).Row
LNextrow = Sheets("Completed").Cells(Rows.Count, "M").End(xlUp).Row + 1
For j = 7 To 37 Step 2
If .Cells(i, j).Value > SQtr Then
If .Cells(i, j).Value < EQtr Then
Sheets("Completed").Range(Cells(LNextrow, 13), Cells(LNextrow, 17)).Value = .Range(.Cells(i, 1), .Cells(i, 5)).Value
End If
End If
Next j
Next i
End With
End Sub
Bookmarks