Gliffix101
Board Regular
- Joined
- Apr 1, 2014
- Messages
- 77
Hi All,
I currently have code that runs and autofilters a field (31) based on the value of "Cancelled", "Initiated", "Outstanding", "Requested", or "Blank".
I'd like to add a logic test that filters the criteria of "Cancelled", "Initiated", "Outstanding", "Requested if Column 32 > 20 days from today", or "Blank".
Any ideas?
Full code below:
I currently have code that runs and autofilters a field (31) based on the value of "Cancelled", "Initiated", "Outstanding", "Requested", or "Blank".
I'd like to add a logic test that filters the criteria of "Cancelled", "Initiated", "Outstanding", "Requested if Column 32 > 20 days from today", or "Blank".
Any ideas?
Full code below:
Code:
Sub A_Review()
Dim LastRow As Long
Dim Rng As Range, str1 As String, str2 As String, strx As String, str3 As String, str4 As String, str5 As String
Dim i As Long, wsName As String, temp As String
Dim arrResults
Dim b As Long
Application.ScreenUpdating = False
With Sheets("Combined")
LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
Set Rng = .Range("A1:EV" & LastRow)
End With
With Sheets("Search Form")
str1 = .Range("E8").Text
str2 = .Range("E12").Text
str3 = .Range("E16").Text
str4 = .Range("E20").Text
str5 = .Range("L12").Text
End With
Sheets.Add After:=Sheets("Search Form")
ActiveSheet.Name = ("Results")
Sheets("Combined").Select
ActiveSheet.AutoFilterMode = False
Rng.AutoFilter Field:=31, Criteria1:=Array("Cancelled", "Initiated", "Outstanding", "Requested", ""), Operator:=xlFilterValues
If y > 0 Then Rng.AutoFilter Field:=16, Criteria1:=(arrResults), Operator:=xlFilterValues
If Not str1 = "" Then Rng.AutoFilter Field:=4, Criteria1:=str1
If Not str2 = "" Then Rng.AutoFilter Field:=5, Criteria1:=str2
If Not str3 = "" Then Rng.AutoFilter Field:=151, Criteria1:=str3
If Not str4 = "" Then Rng.AutoFilter Field:=152, Criteria1:=str4
Rng.SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Results").Range("A1")
Application.CutCopyMode = False
Selection.AutoFilter
Sheets("Results").Activate
ActiveSheet.Columns.AutoFit
Rows("1:1").Select
Selection.Find(What:="Current Comment", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.EntireColumn.Select
Selection.ColumnWidth = 40
Sheets("Results").Activate
Columns("AM:ET").Delete
Sheets("Results").Activate
wsName = Format(Date, "mmddyy")
If WorksheetExists(wsName) Then
temp = Left(wsName, 6)
i = 1
wsName = temp & "_" & i
Do While WorksheetExists(wsName)
i = i + 1
wsName = temp & "_" & i
Loop
End If
ActiveSheet.Name = wsName
Range("A1").Select
End Sub