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
Solved

Excel VBA - Conditional copy data from one sheet to other

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

Author Comment

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

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

860 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