Solved

Excel VBA - Conditional copy data from one sheet to other

Posted on 2013-06-07
3
869 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
[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
3 Comments
 
LVL 40

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 41

Author Comment

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

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

729 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