Consulting

Results 1 to 3 of 3

Thread: Solved: input box filter

  1. #1

    Solved: input box filter

    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??

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [vba]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
    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Thanks a lot, you are always suggest professional solutions in very short time :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •