VBA to Filter on variable column
Hi Colin,
Am Mon, 26 May 2014 21:16:52 +0100 schrieb Colin Hayes:
The column would then show those rows corresponding to the user input in
the selected column.
here is a suggestion with only one inputbox to enter column letter and
filter value comma separated:
Sub myFilter()
Dim myStr As String
Dim myArr As Variant
With ActiveSheet
.AutoFilterMode = False
myStr = Application.InputBox("Enter the column letter" _
& "and the filter value comma separated", _
"Column and Value Choice", Type:=2)
If myStr = "" Or myStr = "False" Then Exit Sub
myArr = Split(myStr, ",")
.UsedRange.AutoFilter field:=Columns(myArr(0)).Column, _
Criteria1:=Trim(myArr(1))
End With
End Sub
Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
|