Macro for pop up message box for auto-filter entry

R

Roady

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!
 
L

Luke M

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
 
Joined
Jan 21, 2009
Messages
1
Reaction score
0
Hi,


I'm using a variation of your original code:

Sub FILTRO()
'
''
Dim Low As Integer
Dim High As Integer
Low = InputBox("Give me the Low", "LOW")
High = InputBox("Give me the High", "High")

Selection.AutoFilter Field:=4, criteria1:=">=*" & Low & "*", Operator:=xlAnd, _
criteria2:="<=" & High
End Sub


But it doesn't seem to work. Can you help me with this? I'm trying to get the user to input a value between one number and another (the high and the low) and having it return the rows that match that criteria which are inbetween the two numbers.

Thanks for your time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top