Results 1 to 10 of 10

Need code to copy data based on filter criteria to new workbook as save in a file location

Threaded View

  1. #1
    Registered User
    Join Date
    07-09-2014
    Location
    Naperville, IL
    MS-Off Ver
    office 2013
    Posts
    29

    Need code to copy data based on filter criteria to new workbook as save in a file location

    Hello,

    I have a data set with 4 columns. I need to copy all data for each sales rep to a new workbook and save the file in a network location. I have the code to do this for one rep, but my actual file has about 50 reps. I'm having trouble looping through the filter criteria and creating new workbook names for each of the reps. Here is the code I have so far:

    I have also attached the file. Any help is greatly appreciated. Thanks.

    
    Sub TEST()
    '
    ' TEST Macro
    '
        Dim wb As Workbook
        Dim ws As Worksheet
        
        Set ws = ActiveSheet
        Set wb = Workbooks.Add
    '
        
        ActiveSheet.Range("A:D").AutoFilter Field:=1, Criteria1:="john"
        Range("A1").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Copy
        Sheets.Add After:=Sheets(Sheets.Count)
        Range("A1").Select
        ActiveSheet.Paste
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveSheet.Copy before:=wb.Sheets(1)
        wb.SaveAs "file location"
        
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA code to filter and copy data to new workbook
    By eunice_hor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-21-2014, 03:45 AM
  2. Macro to Auto save a backup copy in a seperate location OR save file with a pop up
    By kdsanderson30 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-12-2014, 12:38 PM
  3. Want to open file, copy filtered data to new workbook and at save as new file
    By satishdu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-25-2014, 12:39 PM
  4. Copy, edit and save workbook to same location as source data file, not macro file.
    By Jasonhouse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2014, 09:01 AM
  5. Replies: 9
    Last Post: 06-24-2013, 04:14 PM

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