ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Ask user for input during marco (https://www.excelbanter.com/excel-discussion-misc-queries/55809-ask-user-input-during-marco.html)

TSS

Ask user for input during marco
 
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


Bob Phillips

Ask user for input during marco
 
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)


"TSS" wrote in message
...
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





All times are GMT +1. The time now is 07:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com