Gliffix101
Board Regular
- Joined
- Apr 1, 2014
- Messages
- 81
Hello,
Below is a copy of the script I'm running. I have a form on "Search Form" tab that allows users to enter data into a particular cell and the form filters the "Combined" data sheet on these values. Today, I started getting this run time error on the LAST line of an IF statement (If Not str7 = "" Then Rng.AuotFilter Field:=161, Criteria1:=str7). I can update the form and str1, str2, str6, str3, and str4 all work. I am getting the issue on str7. Any ideas?
Below is a copy of the script I'm running. I have a form on "Search Form" tab that allows users to enter data into a particular cell and the form filters the "Combined" data sheet on these values. Today, I started getting this run time error on the LAST line of an IF statement (If Not str7 = "" Then Rng.AuotFilter Field:=161, Criteria1:=str7). I can update the form and str1, str2, str6, str3, and str4 all work. I am getting the issue on str7. Any ideas?
Code:
Sub Felicia_Template()
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, str6 As String, str7 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:FE" & 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
str6 = .Range("E24").Text
str7 = .Range("E28").Text
End With
Sheets.Add After:=Sheets("Search Form")
ActiveSheet.Name = ("Results")
Sheets("Combined").Select
ActiveSheet.AutoFilterMode = False
Rng.AutoFilter Field:=6, Criteria1:="<>", Operator:=xlFilterValues
If y > 0 Then Rng.AutoFilter Field:=20, 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 str6 = "" Then Rng.AutoFilter Field:=6, Criteria1:=str6
If Not str3 = "" Then Rng.AutoFilter Field:=159, Criteria1:=str3
If Not str4 = "" Then Rng.AutoFilter Field:=160, Criteria1:=str4
If Not str7 = "" Then Rng.AuotFilter Field:=161, Criteria1:=str7
Rng.SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Results").Range("A1")
Application.CutCopyMode = False
Selection.AutoFilter
Sheets("Results").Activate
ActiveSheet.Columns.AutoFit
Worksheets("Results").Range("A:FE").Columns.AutoFit
Rows("2:99999").RowHeight = 15
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("BV:FD").Delete
Columns("AQ:BR").Delete
Columns("AI:AM").Delete
Columns("AG:AG").Delete
Columns("AE:AE").Delete
Columns("AB:AC").Delete
Columns("Z:Z").Delete
Columns("X:X").Delete
Columns("U:V").Delete
Columns("R:R").Delete
Columns("M:P").Delete
Columns("G:K").Delete
Columns("C:E").Delete
Columns("H:I").Insert Shift:=xlToRight
Range("H1").Value = "Outstanding Borrower Docs"
Range("I1").Value = "Date Last Contacted"
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