ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Custom Filter in a Macro (https://www.excelbanter.com/excel-discussion-misc-queries/210903-custom-filter-macro.html)

Mike The Newb

Custom Filter in a Macro
 
I would like the Macro to prompt the user for what they want to see within
the filter; the user input will vary. What's the "prompt user" code?

Another question - I want to print the results which could vary in number of
rows - can a Macro accommodate that? How so?

Thank you in advance for your time and consideration.

Regards,
Mike


Sheeloo[_3_]

Custom Filter in a Macro
 
1. Search Help for INPUTBOX

Following is the example from Help
Dim Message, Title, Default, MyValue
Message = "Enter a value between 1 and 3" ' Set prompt.
Title = "InputBox Demo" ' Set title.
Default = "1" ' Set default.
' Display message, title, and default value.
MyValue = InputBox(Message, Title, Default)

' Use Helpfile and context. The Help button is added automatically.
MyValue = InputBox(Message, Title, , , , "DEMO.HLP", 10)

' Display dialog box at position 100, 100.
MyValue = InputBox(Message, Title, Default, 100, 100)

2. You can set the print area through code like the example below (again
from Help);
ActiveSheet.PageSetup.PrintArea = _
ActiveCell.CurrentRegion.Address

"Mike The Newb" wrote:

I would like the Macro to prompt the user for what they want to see within
the filter; the user input will vary. What's the "prompt user" code?

Another question - I want to print the results which could vary in number of
rows - can a Macro accommodate that? How so?

Thank you in advance for your time and consideration.

Regards,
Mike


Mike The Newb

Custom Filter in a Macro
 
I'm sorry, I do not understand this - I'm a Newb.

I record Macros manually, I do not write VB Script. My simple Macro looks
like this:
Selection.AutoFilter Field:=1, Criteria1:="=7777", Operator:=xlAnd
End Sub

I need the criteria1 to be variable (as apposed to always 7777) as input by
the user when prompted after kicking off the macro.

Regards,
Mike

"Sheeloo" wrote:

1. Search Help for INPUTBOX

Following is the example from Help
Dim Message, Title, Default, MyValue
Message = "Enter a value between 1 and 3" ' Set prompt.
Title = "InputBox Demo" ' Set title.
Default = "1" ' Set default.
' Display message, title, and default value.
MyValue = InputBox(Message, Title, Default)

' Use Helpfile and context. The Help button is added automatically.
MyValue = InputBox(Message, Title, , , , "DEMO.HLP", 10)

' Display dialog box at position 100, 100.
MyValue = InputBox(Message, Title, Default, 100, 100)

2. You can set the print area through code like the example below (again
from Help);
ActiveSheet.PageSetup.PrintArea = _
ActiveCell.CurrentRegion.Address

"Mike The Newb" wrote:

I would like the Macro to prompt the user for what they want to see within
the filter; the user input will vary. What's the "prompt user" code?

Another question - I want to print the results which could vary in number of
rows - can a Macro accommodate that? How so?

Thank you in advance for your time and consideration.

Regards,
Mike



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

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