+ Reply to Thread
Results 1 to 5 of 5

Divide an excel sheet into multiple files so that each column becomes a separate file?

  1. #1
    Registered User
    Join Date
    03-29-2020
    Location
    Islamabad, Pakistan
    MS-Off Ver
    Office 365
    Posts
    8

    Divide an excel sheet into multiple files so that each column becomes a separate file?

    I have a large dataset containing data for various cities, and I need to separate the data of each city into a separate file so I can work on them further separately.
    I've attached example sheets, the original file need to get transformed into three separate files containing data for separate cities. I would love any help on this?
    Attached Files Attached Files

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Divide an excel sheet into multiple files so that each column becomes a separate file?

    Coy the code to the standard code module1.

    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

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

    Cool Hi ! Try this !


    As a VBA beginner starter demonstration :

    PHP Code: 
    Sub Demo1()
         
    Dim P$, C%
             
    ThisWorkbook.Path Application.PathSeparator
        With Application
            
    .DisplayAlerts False:  .ScreenUpdating False:  .SheetsInNewWorkbook 1
             Workbooks
    .Add
        With Sheet1
    .[A1].CurrentRegion.Columns
                
    [A1].ColumnWidth = .Item(1).ColumnWidth
               
    .Item(1).Copy [A1]
            For 
    2 To .Count
                
    [B1].ColumnWidth = .Item(C).ColumnWidth
               
    .Item(C).Copy [B1]
                
    ActiveWorkbook.SaveAs P & .Cells(C).TextxlOpenXMLWorkbook
            Next
        End With
             ActiveWorkbook
    .Close False
            
    .DisplayAlerts True:   .ScreenUpdating True
        End With
    End Sub 
    ► Do you like it ? ► ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 03-29-2020 at 11:24 PM. Reason: optimization …

  4. #4
    Registered User
    Join Date
    03-29-2020
    Location
    Islamabad, Pakistan
    MS-Off Ver
    Office 365
    Posts
    8

    Re: Divide an excel sheet into multiple files so that each column becomes a separate file?

    Thanks dude, this worked perfectly.

  5. #5
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Divide an excel sheet into multiple files so that each column becomes a separate file?

    Quote Originally Posted by Choochi View Post
    Thanks dude, this worked perfectly.
    Thanks for the rep. Don't forget to mark the thread as solved.
    regards, JLG

+ 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. Replies: 2
    Last Post: 07-05-2016, 03:49 PM
  2. Merge multiple excel files into one file and separate datas into 2 sheets
    By 2013boris in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-14-2014, 05:57 AM
  3. Divide worsheet and save as separate files
    By Colin Hayes in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  4. Divide worsheet and save as separate files
    By Colin Hayes in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 AM
  5. Divide worsheet and save as separate files
    By Colin Hayes in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  6. [SOLVED] Divide worsheet and save as separate files
    By Colin Hayes in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  7. [SOLVED] Divide worsheet and save as separate files
    By Colin Hayes in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-28-2005, 05:05 PM

Tags for this Thread

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