+ Reply to Thread
Results 1 to 3 of 3

Creating a macro to split data into separate workbooks

  1. #1
    Registered User
    Join Date
    12-06-2013
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Creating a macro to split data into separate workbooks

    Hi - I have a data file that contains the following columns: Name, Address, City, State, Zip, Region Name

    I would like to create a macro that would break this data down into separate workbook by region. There are 9 different regions.

    I would also like to save these files to a specific path on my desktop.

    Attached is an example file. Any help would be appreciated! Thanks!
    Attached Files Attached Files
    Last edited by jfish07; 08-26-2019 at 03:57 PM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this …


    As we are not on a mind readers forum, you just must add the codeline to save each workbook 'to a specific path on the desktop'
    - as you can easily use the Macro Recorder or just reading the VBA help -
    so paste this beginner starter demonstration to the DATA worksheet module :

    PHP Code: 
    Sub Demo1()
        Const 
    6
          Dim Rf 
    As RangeRg As Range
          Application
    .ScreenUpdating False
    With 
    [A1].CurrentRegion.Rows
         
    .Sort .Cells(C), xlAscendingHeader:=xlYes
          Set Rf 
    = .Cells(2C)
        While 
    Rf.Row <= .Count
          Set Rg 
    = .Columns(C).Find(Rf.Value2, , xlValuesxlWhole, , xlPrevious)
          
    Workbooks.Add
         
    .Item(1).Copy ActiveSheet.[A1]
         .
    Item(Rf.Row ":" Rg.Row).Copy ActiveSheet.[A2]
                
          
    Set Rf Rg(2)
        
    Wend
    End With
          Set Rf 
    Nothing:   Set Rg Nothing
          Application
    .ScreenUpdating True
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  3. #3
    Registered User
    Join Date
    12-06-2013
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Hi ! Try this …

    Thanks for the help!

+ 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. VBA to Split Worksheets into separate Workbooks by Tab Name
    By krissysteen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-26-2019, 01:56 PM
  2. [SOLVED] VBA to split document into separate workbooks
    By epidemik in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-03-2017, 11:48 AM
  3. Macro to Split Data into Separate Workbook.
    By kenadams378 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-24-2015, 06:26 AM
  4. Macro to Split Data into separate sheets
    By zahinullah in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-26-2013, 06:41 PM
  5. Macro to Split Data Onto Separate Sheets
    By kestefon in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-20-2013, 11:02 AM
  6. [SOLVED] Macro to Split Workbook into separate Workbooks
    By jmurray in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-14-2009, 04:44 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