G
golf4
Hi, everyone -
I have a quick query that I was hoping to get some help with. I have
created a rent comparability tool, for my employer, that uses the
Auto-Filter to filter a database of housing unit information
("Comparability_Data") using 4 filter criteria, and shows the filtered
results in Sheet1. I have included the code below:
Private Sub CommandButton1_Click() 'Search for Comparable units'
Dim str As String
str = InputBox("Enter The CITY You Are Searching For:")
Sheets("Comparability_Data").UsedRange.AutoFilter Field:=2,
Criteria1:="=*" & str & "*", Operator:=xlAnd
str = InputBox("Enter The UNIT TYPE You Are Searching For:")
Sheets("Comparability_Data").UsedRange.AutoFilter Field:=3,
Criteria1:="=*" & str & "*", Operator:=xlAnd
cryMin = InputBox("Enter The MINIMUM BR SIZE Of Unit:")
cryMax = InputBox("Enter The MAXIMUM BR SIZE Of Unit:")
Sheets("Comparability_Data").UsedRange.AutoFilter Field:=8,
Criteria1:="<=" & cryMax, Operator:=xlAnd, Criteria2:=">=" & cryMin
cryMin = InputBox("Enter The MINIMUM RENT AMOUNT You Are Searching
For:")
cryMax = InputBox("Enter The MAXIMUM RENT AMOUNT You Are Searching:")
Sheets("Comparability_Data").UsedRange.AutoFilter Field:=6,
Criteria1:="<=" & cryMax, Operator:=xlAnd, Criteria2:=">=" & cryMin
cryMin = InputBox("Enter The MINIMUM YEAR BUILT of Unit:")
cryMax = InputBox("Enter The MAXIMUM YEAR BUILT Of Unit:")
Sheets("Comparability_Data").UsedRange.AutoFilter Field:=9,
Criteria1:="<=" & cryMax, Operator:=xlAnd, Criteria2:=">=" & cryMin
Sheets("sheet1").Range("A19:Ac39").Clear
Sheets("Comparability_Data").Range("a1:I16").SpecialCells(xlCellTypeVisible).Copy
Destination:=Sheets("sheet1").Range("a19")
Unload UserForm2
Sheets("SHEET1").Range("A1").Select
End Sub
My question is how would I modify the code to identify the filter
criteria used so that it would also appear on Sheet1? I was thinking,
maybe, in the footer or somewhere else visible on Sheet1.
Any help would be great --- Thanks!!!
Golf
I have a quick query that I was hoping to get some help with. I have
created a rent comparability tool, for my employer, that uses the
Auto-Filter to filter a database of housing unit information
("Comparability_Data") using 4 filter criteria, and shows the filtered
results in Sheet1. I have included the code below:
Private Sub CommandButton1_Click() 'Search for Comparable units'
Dim str As String
str = InputBox("Enter The CITY You Are Searching For:")
Sheets("Comparability_Data").UsedRange.AutoFilter Field:=2,
Criteria1:="=*" & str & "*", Operator:=xlAnd
str = InputBox("Enter The UNIT TYPE You Are Searching For:")
Sheets("Comparability_Data").UsedRange.AutoFilter Field:=3,
Criteria1:="=*" & str & "*", Operator:=xlAnd
cryMin = InputBox("Enter The MINIMUM BR SIZE Of Unit:")
cryMax = InputBox("Enter The MAXIMUM BR SIZE Of Unit:")
Sheets("Comparability_Data").UsedRange.AutoFilter Field:=8,
Criteria1:="<=" & cryMax, Operator:=xlAnd, Criteria2:=">=" & cryMin
cryMin = InputBox("Enter The MINIMUM RENT AMOUNT You Are Searching
For:")
cryMax = InputBox("Enter The MAXIMUM RENT AMOUNT You Are Searching:")
Sheets("Comparability_Data").UsedRange.AutoFilter Field:=6,
Criteria1:="<=" & cryMax, Operator:=xlAnd, Criteria2:=">=" & cryMin
cryMin = InputBox("Enter The MINIMUM YEAR BUILT of Unit:")
cryMax = InputBox("Enter The MAXIMUM YEAR BUILT Of Unit:")
Sheets("Comparability_Data").UsedRange.AutoFilter Field:=9,
Criteria1:="<=" & cryMax, Operator:=xlAnd, Criteria2:=">=" & cryMin
Sheets("sheet1").Range("A19:Ac39").Clear
Sheets("Comparability_Data").Range("a1:I16").SpecialCells(xlCellTypeVisible).Copy
Destination:=Sheets("sheet1").Range("a19")
Unload UserForm2
Sheets("SHEET1").Range("A1").Select
End Sub
My question is how would I modify the code to identify the filter
criteria used so that it would also appear on Sheet1? I was thinking,
maybe, in the footer or somewhere else visible on Sheet1.
Any help would be great --- Thanks!!!
Golf