Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,574
Default using advanced filter in VBA with a dynamic range

I recorded the following macro, which applies the Advanced Filter to a range
of data. This range of data changes from month to month, in terms of the
number of rows of data. The criteria range and the number of columns do not
change. How can I modify it to automatically adjust the filter range?

Here's the code:

Sub AdvFilterTest()
'
' AdvFilterTest Macro
' Macro recorded 10/2/2006 by df78700
'

'
Range("A5:S42207").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _
Range("U1:U5"), CopyToRange:=Range("V1"), Unique:=False
End Sub


Basically, the thing that would change from month to month is the cell in
column S of the first range given.

Hope I've made this clear.

Thanks,

Dave
--
Brevity is the soul of wit.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default using advanced filter in VBA with a dynamic range

Try:
Range("A5:S" & Range("S" & Rows.Count).End(xlUp))
--
Charles Chickering

"A good example is twice the value of good advice."


"Dave F" wrote:

I recorded the following macro, which applies the Advanced Filter to a range
of data. This range of data changes from month to month, in terms of the
number of rows of data. The criteria range and the number of columns do not
change. How can I modify it to automatically adjust the filter range?

Here's the code:

Sub AdvFilterTest()
'
' AdvFilterTest Macro
' Macro recorded 10/2/2006 by df78700
'

'
Range("A5:S42207").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _
Range("U1:U5"), CopyToRange:=Range("V1"), Unique:=False
End Sub


Basically, the thing that would change from month to month is the cell in
column S of the first range given.

Hope I've made this clear.

Thanks,

Dave
--
Brevity is the soul of wit.

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 using a range name as the criteria Joe Excel Worksheet Functions 1 December 27th 08 06:23 PM
Advanced filter a dynamic date range oneandoneis2 Excel Worksheet Functions 2 April 6th 06 08:57 AM
Advanced Filter to Dynamic Range John Excel Programming 5 November 12th 05 09:12 PM
advanced filter a range Il Principe Excel Worksheet Functions 2 August 1st 05 03:27 PM
"Criteria Range" in the "Data/Filter/Advanced Filter" to select Du TC Excel Worksheet Functions 1 May 12th 05 02:06 AM


All times are GMT +1. The time now is 03:10 PM.

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

About Us

"It's about Microsoft Excel"