Results 1 to 1 of 1

Macro to copy worksheet data to another worksheet based on criteria

Threaded View

  1. #1
    Registered User
    Join Date
    03-31-2011
    Location
    Canada, Toronto
    MS-Off Ver
    Excel 2003
    Posts
    9

    Macro to copy worksheet data to another worksheet based on criteria

    Hi everyone !

    Can someody help me create a macro that will search data from a range of cells based on one criteria and copy the entire data to a new worksheet ?

    Example I have a list of Channel Names :

    Cartoon Network
    Disney Channel
    CNN
    BBC

    I want all the Data of CNN to be copied on another worksheet named CNN. The worksheet should be created with a macro.

    Here is my code :
    
    Sub NewSheet()
    
    Dim Rang As Range
    Dim WS As Worksheet
    Set WS = Sheets.Add
    
    
    Set Rang1 = Workbooks("Channels").Sheets("ORG").Range("A1").CurrentRegion
    Set Rang2 = Workbooks("Channels").Sheets("ORG").Range("A1").CurrentRegion
    
    Rang1.AutoFilter Field:=3, Criteria1:="CNN"
    
    
    Rang1.copy
    
    WS.Name = "CNN"
    
    Sheets("CNN").Activate
    
    ActiveSheet.Paste
    
    
    Sheets("ORG").Activate
    
    
    Rang2.AutoFilter Field:=3, Criteria1:="Cartoon Network"
    
    Rang2.copy
    
    WS.Name = "Cartoon Network"
    
    Sheets("Cartoon Network").Activate
    
    ActiveSheet.Paste
    
    Sheets("ORG").Activate
    
    
    End Sub
    Thanks in advance !
    Last edited by excelvb; 04-07-2011 at 06:48 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1