+ Reply to Thread
Results 1 to 6 of 6

Need help with a VBA code for distributing data

  1. #1
    Registered User
    Join Date
    11-17-2014
    Location
    panama
    MS-Off Ver
    2013
    Posts
    2

    Need help with a VBA code for distributing data

    Hello,


    I got a work project that requires me to create several documents out one Master Document.

    Here's the problem, the master document has filter cell, which I need in order to filter the massive amount of data and then create a new document with only the filtered data. The problem is that I have to create a large amount of those new documents, and copy-pasting will take forever. I thought I had solved the problem by copying the master sheet several times and then filtering the information on each sheet (each sheet has different filters) and then using the code below to make every sheet into a new document. This seem like a viable solution until I realized it copies the complete data but only showed the filtered data.




    Sub Splitbook()
    Dim xPath As String
    xPath = Application.ActiveWorkbook.Path
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    For Each xWs In ThisWorkbook.Sheets
    xWs.Copy
    Application.ActiveWorkbook.SaveAs Filename:=xPath & "" & xWs.Name & ".xls"
    Application.ActiveWorkbook.Close False
    Next
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    End Sub


    What I need is a code that will copy the filtered data WITHOUT the master data and create a new doc with only the filtered data.

    Example. (Bold means that the data can be filtered)


    A1 A2 A3 A4 B1 B2 B3 B4 C1 C2 C3 C4 ( MASTER DATA)

    A1 A3 A4 B1 B3 B4 C1 C3 C4 (FILTERED DATA - AL CELLS CONTAINING "2" ARE NOT SHOWN)

    A1 A3 A4 B1 B3 B4 C1 C3 C4 (NEW DOWCUMENT)

    The new document will only contain the filtered data. Not the master data filtered.



    Thanks in advance.
    Last edited by cspeid03; 12-21-2016 at 05:05 PM.

  2. #2
    Forum Contributor
    Join Date
    05-02-2015
    Location
    calgary alberta
    MS-Off Ver
    2012
    Posts
    205

    Re: Need help with a VBA code for distributing data

    i can try this but it might be easier to attach a simple copy of your data so we can see where you are applying you filters and what you want the new workbook to be labeled as?

  3. #3
    Registered User
    Join Date
    11-17-2014
    Location
    panama
    MS-Off Ver
    2013
    Posts
    2

    Re: Need help with a VBA code for distributing data

    as.png


    For somereason I cant upload the excel file, so Im uploading a screenshot instead.

  4. #4
    Forum Contributor
    Join Date
    05-02-2015
    Location
    calgary alberta
    MS-Off Ver
    2012
    Posts
    205

    Re: Need help with a VBA code for distributing data

    Well in no way do I feel like retypung your data and guessing how you filter it

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    12,963

    Re: Need help with a VBA code for distributing data

    deleted......
    Last edited by protonLeah; 12-21-2016 at 11:03 PM.
    Ben Van Johnson

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,378

    Re: Need help with a VBA code for distributing data

    Hi cspeid03,

    I think you are looking for the Advanced*Filter, where you filter the master data to another sheet (or a different part of the same sheet) and then copy that data.
    Read about them at:
    http://www.excel-easy.com/examples/advanced-filter.html
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Distributing values or data with a group???
    By FifiNguyen in forum Excel General
    Replies: 0
    Last Post: 03-01-2014, 03:46 AM
  2. Distributing data from one column to multiple
    By MechanicalFrito in forum Excel General
    Replies: 1
    Last Post: 08-20-2012, 01:18 PM
  3. Distributing Excel VBA code
    By excelbobabc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-08-2011, 09:48 PM
  4. Distributing data in different worksheets with Macros
    By robertse in forum Excel General
    Replies: 2
    Last Post: 06-02-2010, 01:29 PM
  5. Distributing Data
    By Milnet in forum Excel General
    Replies: 6
    Last Post: 08-10-2009, 02:55 AM
  6. distributing data into multiple cells
    By jaspreet in forum Excel General
    Replies: 1
    Last Post: 05-28-2005, 04:31 AM

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