Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    May 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sub Macro2()
    Range("S8:S669").Select
    ActiveWindow.SmallScroll Down:=-3
    Selection.AutoFilter
    Selection.AutoFilter Field:=1, Criteria1:="*InputBox("Number")**", Operator:=xlAnd
    ActiveWindow.SmallScroll Down:=12
    End Sub


    I am having a problem using autofilter to find an exact number in a column of cells. The code above is what I am trying to use. Can anybody tell me what is wrong with it and how I can correct my mistake. I am using Office Excel 2003.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Welcome to the Lounge!

    You can't include a function such as InputBox within a quoted string; you must concatenate it. But since you want to find an exact number, that isn't necessary here. You should be able to use the following:

    Code:
    Sub Macro2()
      Dim dblNum As Double
      dblNum = Application.InputBox(Prompt:="Number", Type:=1)
      Range("S8:S669").AutoFilter Field:=1, Criteria1:=dblNum
    End Sub

Posting Permissions

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