View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Luke M Luke M is offline
external usenet poster
 
Posts: 2,722
Default Macro for pop up message box for auto-filter entry

You can enter this macro into the VBA editor, and then create a button (from
forms toolbar, or an picture from drawing toolbar) and link the macro to it.

Sub FilterChoice()

Dim Choice1 As String
Dim Choice2 As String


'Input box format is question, title
Choice1 = InputBox("What is the first string?", "First String")
Choice2 = InputBox("What is the second string?", "Second String")

'Field number equals column number, where A = 1, B = 2, etc.
Selection.AutoFilter Field:=1, Criteria1:="=*" & Choice1 & "*",
Operator:=xlOr, _
Criteria2:="=" & Choice2
End Sub


--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Roady" wrote:

Hello:

I have a spreadsheet with auto-filters. I would like to create a macro
button that works as a shortcut for those who would like to perform a certain
search function so that the users do not have to remember how to filter- all
they will need to do is enter in a series of numbers in a pop-up message box
and then hit 'ok'.

Steps are as follows:

Select auto-filter drop-down on Col. A
Select 'custom filter'
Select dropdown 'Contains'
{Enter in the string of numbers that user has entered into the popup box
into the box at right}
Select 'or' button
Select dropdown 'Equals'
{Again, enter in the string of numbers that user has entered into the popup
box into the box at right}
Hit 'Ok' button

Can you help with coding? thank you!