Solved

Excel VBA - Conditional copy data from one sheet to other

Posted on 2013-06-07
3
840 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

746 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

9 Experts available now in Live!

Get 1:1 Help Now