Solved

Filter and Copy question

Posted on 2013-11-18
1
208 Views
Last Modified: 2013-11-18
Hi Guys, I have a text file that I open every day and filter in the 3rd row on the Differences column for anything bigger than 0 and then copy and paste it. I am currently using Current Region, instead of EndXl(Down) as the file usually has no differences, but I do not wish to copy and paste rows 1 and 2. My code is this:

Workbooks.Open Filename:= _
        "V:\Treasury Finance Controls\Ledger v SS Recs\Recs - Murex_GBO\2013 Recs\11_2013 Recs\BS\Full Ledger\" & Prevday & "\" & "CreditBSRec_Daily_" & Prevday & ".xlsx"

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

    Range("A4:r4").CurrentRegion.Select

Is there a way I can just copy the 3rd row if there are no differences. I enclose the file,
CreditBSRec-Daily-20131106-05355.txt
0
Comment
Question by:Justincut
1 Comment
 
LVL 6

Accepted Solution

by:
Michael earned 500 total points
ID: 39656306
The following code will take your Range("A4:r4").CurrentRegion and exclude the first two rows:

Set rng = Range("A4:r4").CurrentRegion
Set rng = rng.Resize(rng.Rows.Count - 2).Offset(2)

Open in new window

Then, you can use rng.copy and paste it to the desired location.

Joop
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

770 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