PDA

View Full Version : Solved: input box filter



justdream
02-26-2011, 12:27 PM
Dears,

I'm using input box filter to allow users entering their required data to be selected and filtered
as shown


Area = InputBox("Enter your required Area")
Range("A1").AutoFilter Field:=1, Criteria1:=Area

but I faced special case: some users want to select two variable (example: filter for Asia and USA)

how could I let users select multiple inputs
using above input box filter??

mdmackillop
02-26-2011, 12:41 PM
Option Explicit
Sub Test()

Dim Area As String
Dim Data As Variant

Area = InputBox("Enter your required Area(s) - comma separated")
If InStr(1, Area, ",") > 0 Then
Data = Split(Area, ",")
Range("A1").AutoFilter Field:=1, Criteria1:=Trim(Data(0)), Operator:=xlOr, Criteria2:=Trim(Data(1))
Else
Range("A1").AutoFilter Field:=1, Criteria1:=Area
End If
End Sub

justdream
02-26-2011, 12:49 PM
Thanks a lot, you are always suggest professional solutions in very short time :-)