Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 27
Default Advanced Filter Macro

Hi,

i tried to write a macro for advanced filter as below but it doesn't work.
Please help.

The main data are in the "Raw" worksheet & the criterias is in the "Bank
List" worksheet.

With Worksheets("Bank List")
Set myrng = .Range("A1:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With

Worksheets("Raw").Cells.AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:=Sheets("Bank List").Range(myrng), Unique:=False

Thanks.

Dolphin
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Advanced Filter Macro

I think you have the source and destination ranges backwards. This code works

With Worksheets("Bank List")
Set myrng = .Range("A1:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With

myrng.AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=Worksheets("Raw").Range("A1"), Unique:=False

"Dolphinv4" wrote:

Hi,

i tried to write a macro for advanced filter as below but it doesn't work.
Please help.

The main data are in the "Raw" worksheet & the criterias is in the "Bank
List" worksheet.

With Worksheets("Bank List")
Set myrng = .Range("A1:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With

Worksheets("Raw").Cells.AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:=Sheets("Bank List").Range(myrng), Unique:=False

Thanks.

Dolphin

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Advanced Filter Macro

myrng is already a range.

That means that excel/vba knows all about it--it knows that it's on the Bank
List worksheet. So you can't specify that with "sheets("bank
list").range(myrng).

And you can't wrap myrng with range(), either.

Worksheets("Raw").Cells.AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=myrng, Unique:=False


But I'd be more specific. I'd use the same kind of code to tell what column to
filter on the Raw worksheet (I changed some variable names, too):

Dim myCriteriaRng As Range
Dim myRngToFilter As Range

With Worksheets("Bank List")
Set myCriteriaRng = .Range("A1:A" _
& .Cells(.Rows.Count, "A").End(xlUp).Row)
End With

With Worksheets("raw")
Set myRngToFilter = .Range("a1:A" _
& .Cells(.Rows.Count, "A").End(xlUp).Row)
End With

myRngToFilter.AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=myCriteriaRng, Unique:=False

Dolphinv4 wrote:

Hi,

i tried to write a macro for advanced filter as below but it doesn't work.
Please help.

The main data are in the "Raw" worksheet & the criterias is in the "Bank
List" worksheet.

With Worksheets("Bank List")
Set myrng = .Range("A1:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With

Worksheets("Raw").Cells.AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:=Sheets("Bank List").Range(myrng), Unique:=False

Thanks.

Dolphin


--

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
Advanced Filter - filter rows < jaws4518 Excel Discussion (Misc queries) 3 November 1st 06 05:48 PM
Why won't advanced filter return filter results? jaws4518 Excel Worksheet Functions 5 September 12th 06 06:11 PM
How do I use advanced filter to filter for blank cells? Monique Excel Discussion (Misc queries) 2 March 21st 06 06:43 PM
"Criteria Range" in the "Data/Filter/Advanced Filter" to select Du TC Excel Worksheet Functions 1 May 12th 05 02:06 AM
advanced filter won't allow me to filter on bracketed text (-456.2 LucianoG Excel Discussion (Misc queries) 1 December 6th 04 08:38 PM


All times are GMT +1. The time now is 12:56 PM.

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"