Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel VBA - Conditional copy data from one sheet to other

Posted on 2013-06-07
3
Medium Priority
?
883 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 2000 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

704 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