Godders199
Active Member
- Joined
- Mar 2, 2017
- Messages
- 313
- Office Version
- 2013
Hello, i use the following code, which might be long winded but works, I just need to change the criteria , so if range G17 is blank it just returns the results based on C11 and C20. currently it will return "no Matches found"
Is there any code to do this?
Sheets("cases available ").Select
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilter.ShowAllData
Sheets("instructions ").Select
Dim Usdrws As Long
Usdrws = Sheets("cases available ").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Dim Startdate As Long, Enddate As Long
Startdate = DateSerial(Year(Date), Month(Date), Day(Date) - 14)
Enddate = DateSerial(Year(Date), Month(Date), Day(Date) + 0)
With Sheets("cases available ").Range("a:ab")
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilter.ShowAllData
.AutoFilter field:=8, Criteria1:=Sheets("instructions ").Range("c11").Value, Operator:=xlFilterValues
.AutoFilter field:=11, Criteria1:="=*" & Sheets("instructions ").Range("c20") & "*", Operator:=xlFilterValues
.AutoFilter field:=30, Criteria1:="=*" & Sheets("instructions ").Range("g17") & "*", Operator:=xlFilterValues
.AutoFilter field:=5, Criteria1:=">=" & Startdate, Operator:=xlFilterValues
End With
If Sheets("cases available ").Range("E1:E" & Usdrws).SpecialCells(xlVisible).Count = 1 Then
MsgBox "No matches re search"
Exit Sub
Is there any code to do this?
Sheets("cases available ").Select
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilter.ShowAllData
Sheets("instructions ").Select
Dim Usdrws As Long
Usdrws = Sheets("cases available ").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Dim Startdate As Long, Enddate As Long
Startdate = DateSerial(Year(Date), Month(Date), Day(Date) - 14)
Enddate = DateSerial(Year(Date), Month(Date), Day(Date) + 0)
With Sheets("cases available ").Range("a:ab")
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilter.ShowAllData
.AutoFilter field:=8, Criteria1:=Sheets("instructions ").Range("c11").Value, Operator:=xlFilterValues
.AutoFilter field:=11, Criteria1:="=*" & Sheets("instructions ").Range("c20") & "*", Operator:=xlFilterValues
.AutoFilter field:=30, Criteria1:="=*" & Sheets("instructions ").Range("g17") & "*", Operator:=xlFilterValues
.AutoFilter field:=5, Criteria1:=">=" & Startdate, Operator:=xlFilterValues
End With
If Sheets("cases available ").Range("E1:E" & Usdrws).SpecialCells(xlVisible).Count = 1 Then
MsgBox "No matches re search"
Exit Sub