Solved

Filter Range problem in Excel

Posted on 2013-10-23
1
258 Views
Last Modified: 2013-10-23
Hi Guys, I recorded a Macro for a daily process whereby I put an auto-filter on row 3.Then do End(xlDown) and copy the region. However, the Macro recorded the exact Row range and it will be variable every day so I need to adapt it.
Rows("3:3").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$3:$R$166").AutoFilter Field:=13, Criteria1:=">=1", _
        Operator:=xlOr, Criteria2:="<=-1"

Any ideas?

Justin
0
Comment
Question by:Justincut
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
Michael earned 500 total points
ID: 39593783
Hello Justin,

try the following:
Dim lr as long
lr = Cells(Rows.Count, "A").End(xlUp).Row

Rows("3:3").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$3:$R$" & lr).AutoFilter Field:=13, Criteria1:=">=1", _
        Operator:=xlOr, Criteria2:="<=-1"

Open in new window

where Cells(Rows.Count, "A").End(xlUp).Row finds the last row used in column A.
If needed, replace A with a column in which there's always a value in the last row.

--
Btw, you can also leave this part out:
Rows("3:3").Select
    Selection.AutoFilter


So, this works as well:
Rows("3:3").AutoFilter
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
split data by day 21 36
Excel with two IF statements 3 11
Excel VLookup Function Help 11 27
HOW CAN I summarize THE REPEAT NUMBERS 3 28
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question