Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default paste into filter criteria box running macro

I need to create a macro which can filter a list from 2 parameters. It is not possible to copy a value in the criteria box of the filter function while running a macro. It can be done by hand with ctrl-c and ctrl-v but it will not work in the macro
Any clues

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default paste into filter criteria box running macro

You can get to it like:

Option Explicit
Sub testme01()

Dim myFilter As Filter
Dim myOp As String
Dim myCrit1 As String
Dim myCrit2 As String

With ActiveSheet
If .FilterMode Then
Set myFilter = .AutoFilter.Filters(1)
myOp = ""
myCrit1 = ""
myCrit2 = ""
With myFilter
On Error Resume Next
myCrit1 = .Criteria1
myCrit2 = .Criteria2
Select Case .Operator
Case Is = xlAnd: myOp = " And "
Case Is = xlOr: myOp = " Or "
Case Is = xlBottom10Percent: myOp = " bot10pct "
Case Is = xlTop10Items: myOp = " top10items "
Case Is = xlBottom10Items: myOp = " bot10Items "
Case Is = xlTop10Percent: myOp = " top10pct "
End Select
On Error GoTo 0
MsgBox myCrit1 & myOp & myCrit2
End With
End If
End With
End Sub

I looked at the first column in the filtered range:
Set myFilter = .AutoFilter.Filters(1)
stephan brisson wrote:

I need to create a macro which can filter a list from 2 parameters. It is not possible to copy a value in the criteria box of the filter function while running a macro. It can be done by hand with ctrl-c and ctrl-v but it will not work in the macro.
Any clues?


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro filter based on date criteria puiuluipui Excel Discussion (Misc queries) 4 September 19th 09 12:18 PM
Macro to allow auto filter after running password protect Roady Excel Discussion (Misc queries) 1 July 17th 08 06:34 PM
Macro to copy and paste into a custom filter Jtmturner Excel Discussion (Misc queries) 6 February 1st 07 07:14 PM
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
error running a paste macro Redskinsfan Excel Worksheet Functions 1 August 7th 06 08:02 PM


All times are GMT +1. The time now is 04:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"