Ask user for input during marco

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I create a marco for user to run a report for display any site with inventory
less than 15%, but user want to define the percentage for the site. I was
able to define the box for the user input. How can I use the value to excute
the marco? Here is the marco code:

Sub test1()
'
' test1 Macro
' Macro recorded 11/16/2005 by County of Orange
'
' Keyboard Shortcut: Ctrl+Shift+A
'
'Get target value from user
Message = "Change values less than or equal to ..."
Target = InputBox(Message)
Target = Val(Target)


Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="<=15%", Operator:=xlAnd
End Sub

Thanks
 
I think you just need

Selection.AutoFilter Field:=2, Criteria1:="<=" & Target & "%",
Operator:=xlAnd

assuming it is just the number input. If the % is input as well, remove it
from that statement above.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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

Back
Top