Solved

Excel VBA - Conditional copy data from one sheet to other

Posted on 2013-06-07
3
844 Views
Last Modified: 2013-06-13
I have data in Sheet1. Row1 is column headers. Column C name is Title. From Row2 onwards I have data. I want to copy data from Sheet1 to Sheet2 based on data in Title column. I want to exclude the records in Sheet1 if Title has a string like "ABC".

Basically, I want to exclude those records in Sheet1 with Title having "ABC" and copy remaining records to Sheet2. Really apprcieate if anyone helps with a Excel VBA.

Thanks in Advance
Sharath
0
Comment
Question by:Sharath
3 Comments
 
LVL 39

Expert Comment

by:als315
ID: 39231222
Try to prepare sample. One sheet with data and other one with expected result
0
 
LVL 6

Accepted Solution

by:
Michael earned 500 total points
ID: 39231761
Hi Sharath,

here's the code. It's much the same like my previous answer.

Sub filterExclusion()
    
    With Sheets("Sheet1").Range("A1")
        .AutoFilter _
                Field:=3, _
                Criteria1:="<>" & "*ABC*", _
                Operator:=xlFilterValues
        .CurrentRegion.SpecialCells(xlCellTypeVisible).Copy Destination:=Sheets("Sheet2").Range("A1")
        .AutoFilter
    End With
End Sub

Open in new window


Field:=3 applies the filter to column 3(C)
"<>" excludes filtered results with the string that follows

If you mean
Title should not be equal to ABC : "ABC"
Title should not contain ABC: "*ABC*"

Hope this explains it a bit. Any further questions? Let me know!
0
 
LVL 40

Author Comment

by:Sharath
ID: 39246599
Thanks JazzyJoop for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now