+ Reply to Thread
Results 1 to 27 of 27

Spliting up an excel spreadsheet with languages' rows into multiple files

Hybrid View

CaroDuna Spliting up an excel... 08-11-2014, 11:34 AM
p24leclerc Re: Spliting up an excel... 08-11-2014, 08:11 PM
CaroDuna Re: Spliting up an excel... 08-12-2014, 03:49 AM
p24leclerc Re: Spliting up an excel... 08-12-2014, 03:38 PM
CaroDuna Re: Spliting up an excel... 08-13-2014, 02:57 AM
p24leclerc Re: Spliting up an excel... 08-13-2014, 10:57 AM
CaroDuna Re: Spliting up an excel... 08-18-2014, 03:03 AM
p24leclerc Re: Spliting up an excel... 08-18-2014, 08:50 PM
CaroDuna Re: Spliting up an excel... 08-19-2014, 03:38 AM
jindon Re: Spliting up an excel... 08-18-2014, 09:18 PM
CaroDuna Re: Spliting up an excel... 08-19-2014, 03:29 AM
p24leclerc Re: Spliting up an excel... 08-18-2014, 09:54 PM
jindon Re: Spliting up an excel... 08-19-2014, 03:44 AM
jindon Re: Spliting up an excel... 08-19-2014, 03:45 AM
CaroDuna Re: Spliting up an excel... 08-20-2014, 08:41 AM
apo Re: Spliting up an excel... 08-19-2014, 03:56 AM
jindon Re: Spliting up an excel... 08-20-2014, 08:48 AM
CaroDuna Re: Spliting up an excel... 08-20-2014, 09:10 AM
jindon Re: Spliting up an excel... 08-20-2014, 09:17 AM
CaroDuna Re: Spliting up an excel... 08-20-2014, 09:48 AM
jindon Re: Spliting up an excel... 08-20-2014, 09:52 AM
CaroDuna Re: Spliting up an excel... 08-20-2014, 09:56 AM
jindon Re: Spliting up an excel... 08-20-2014, 10:01 AM
CaroDuna Re: Spliting up an excel... 08-20-2014, 10:04 AM
jindon Re: Spliting up an excel... 08-20-2014, 10:09 AM
jindon Re: Spliting up an excel... 08-20-2014, 10:13 AM
CaroDuna Re: Spliting up an excel... 09-09-2014, 11:00 AM
  1. #1
    Registered User
    Join Date
    08-11-2014
    Location
    Luxembourg
    MS-Off Ver
    2010
    Posts
    11

    Spliting up an excel spreadsheet with languages' rows into multiple files

    I have many excel files containing terminological data in 3 different languages:
    The header (first colum) indicates the languages' code (EN, FR, ES) for each row in every file.
    I need to split up every file according to these 3 languages and I should only have 3 final files containing all the rows in each language respectively.

    Many thanks in advance,

    Caro

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Do I understand that your final 3 files would have specific names and that the names will not change?
    Are all the files in the same folder?
    Is there any order to read those files?
    It would be helpfull to attach sample files to work with! Make sure there is no sensitive data in your files.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    08-11-2014
    Location
    Luxembourg
    MS-Off Ver
    2010
    Posts
    11

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    All files are in the same folder indeed and it doesn´t matter in which order they are read.

    It doesn´t matter either how the final files are named. I just need to have 3 files at the end, one for each language containing only the information in the same language.

    Attached you find a sample of the tables.

    Thanks!
    Attached Files Attached Files

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    See attached workbook.
    save this file in the same folder as your other files. Open this workbook and click on the programmed button to start the transfer of all langusges to the 3 sheets (one for each langusge).

    I assumed there was only one sheet in your files.

    The macro will scan all the files in your folder and gather the languages under the same sheet. It will skip any files that have the word "Summary" in it as it is the name of our summary file with the macro in it.

    If you really need 3 separate files, you can save each sheet to a new workbook or if you give me naming specification, I can program it in the macro.

    I did not know about the titles' row. Do they change? If so, I can make the copy of it to be automatic.
    Hope this helps
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-11-2014
    Location
    Luxembourg
    MS-Off Ver
    2010
    Posts
    11

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Many thanks for your help in this, though I haven´t been able to download the file... I got the following error message:

    The page you've been trying to access was blocked.

    Reason: Forbidden file type! An attempt was made to download a forbidden file type.
    Transaction ID is 53EB0B7E85790E02577D.

    As to your question, the titles' row don´t change, so there is no need for you to do anything else in this regard.

    But if you could, it would be much appreciated if you could add something in the macro so that the 3 sheets are then saved as 3 different files. The name of the files could be "University_Projects_EN", "University_Projects_FR" and "University_Projects_ES".

    Many thanks again! This is really useful, as I'll have many other files to process in the same way.

  6. #6
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    The attached file will create the 3 files as requested. They will be saved in the same folder as the other files. The program was modified so those files will not be processed.
    I hope you'll be able to open it this time. In case you have still a problem, here is a link to download it from Dropbox:
    https://dl.dropboxusercontent.com/u/...-FR-EN-ES.xlsm
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-11-2014
    Location
    Luxembourg
    MS-Off Ver
    2010
    Posts
    11

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Hi again!

    I could neither open the attached file (same error as last time) nor the link. For the link it even says "This website is known to distribute malware, or is part of a security incident or cyber threat as reported by the Computer Emergency Response Team (CERT)."

    To be honest, I feel disappointed...

  8. #8
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Reason: Forbidden file type! An attempt was made to download a forbidden file type.
    This certainly comes from your server. You might ask your server master for help about this.
    Have you tried to open it on your private computer? Or someone else computer? Maybe like a librairy one or an internet coffee shop. It's the first time I got this comment.
    I'm not a computer guru so you'll have to ask help from your co-workers or others computer knowledgable peoples you might know.
    Are you on MAC or Windows? It should not prevent you to download this file though.
    Let me know how it goes. Our last option would be to send it to you by direct email but I'm pretty sure you'll be able to make it work somehow.

  9. #9
    Registered User
    Join Date
    08-11-2014
    Location
    Luxembourg
    MS-Off Ver
    2010
    Posts
    11

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Hi p24leclerc!

    I certainly did not try to open the file from another computer, since it supposedly contains a malware. I could try later on tonight when I go back home, but I´ll wait for Jindon's reply first. I have already had a bad experience with a Trojan and I don´t want to spend again days removing it :D
    Thanks for your help! It's much appreciated!

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    See if this works.
    Sub test()
        Dim myDir As String, fn As String, e, x
        With Application.FileDialog(msoFileDialogFolderPicker)
            If .Show Then myDir = .SelectedItems(1) & "\"
        End With
        If myDir = "" Then Exit Sub
        x = Array("EN", "FR", "ES")
        For Each e In x
            With Workbooks.Add
                .SaveAs myDir & e & ".xls"
            End With
        Next
        fn = Dir(myDir & "*.xls")
        Do While fn <> ""
            Select Case True
                Case fn Like "EN.*", fn Like "FR.*", fn Like "ES.*"
                Case Else
                    With Workbooks.Open(myDir & fn).Sheets(1).Cells(1).CurrentRegion
                        .Parent.AutoFilterMode = False
                        For Each e In Array("EN", "FR", "ES")
                            .AutoFilter 1, e
                            If Workbooks(e & ".xls").Sheets(1).Cells(1) = "" Then
                                .Copy Workbooks(e & ".xls").Sheets(1).Cells(1)
                            Else
                                .Offset(1).Copy Workbooks(e & ".xls").Sheets(1).Range("a" & Rows.Count).End(xlUp)(2)
                            End If
                        Next
                        .Parent.Parent.Close False
                    End With
            End Select
            fn = Dir
        Loop
        For Each e In x
            Workbooks(e & ".xls").Close True
        Next
    End Sub

  11. #11
    Registered User
    Join Date
    08-11-2014
    Location
    Luxembourg
    MS-Off Ver
    2010
    Posts
    11

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Hi Jindon!

    Many thanks for helping me out here. I´ve saved the macro in my personal VBA folder and it ran well (the folders ES, EN and FR were created) but when I checked the content of the newly created files it popped-up the following message:

    "The file you are trying to open 'ES.xls', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?"

    I really cannot see the problem here...I have Windows system and Microsoft 2010.

    Also, I wanted to ask you how do I run the macro on all files at the same time? Cause I need to have at the end only 3 files, one for each language containing only the information for that same language.

    Many thanks again!!!

  12. #12
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    To Jindon,
    Génial.
    You might want to check if the files (EN, FR and ES) exist before trying to create new ones.
    And Caro needs to know that this macro will have to be placed in the Personal.XLSB section of VBE to work.

    But again, I really like you mind structure in your code. I'd love to be able to do this myself.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Duplicagte///

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Try change all ".xls" to ".xlsx"
    Also, I wanted to ask you how do I run the macro on all files at the same time?
    What do you mean by "all files"?

  15. #15
    Registered User
    Join Date
    08-11-2014
    Location
    Luxembourg
    MS-Off Ver
    2010
    Posts
    11

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    I´ve changed the extension but although I didn´t get the same message, the 3 created files were empty.
    By all files I mean that I need to automise the spliting of language rows from different xlsx files. I have aprox. 100 xlsx files that look like the sample table attached above and I need to have that information saved as 3 files (one for each language).

  16. #16
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Hi CaroDuna and p24leclerc,

    Just to let you know.. I downloaded both files that p24leclerc attached without issue..

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Sounds the data range doesn't start from 1st row...

    By the way
    fn = Dir(myDir & "*.xls")
    This extension should not be changed...

  18. #18
    Registered User
    Join Date
    08-11-2014
    Location
    Luxembourg
    MS-Off Ver
    2010
    Posts
    11

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Table_Sample.xlsBy not changing the extension in that string I get an error.
    The data range does beginn as from the 1st row... attached you find a sample table if you'd like to have a look at.

  19. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    The code should look like
    Sub test()
        Dim myDir As String, fn As String, e, x
        With Application.FileDialog(msoFileDialogFolderPicker)
            If .Show Then myDir = .SelectedItems(1) & "\"
        End With
        If myDir = "" Then Exit Sub
        x = Array("EN", "FR", "ES")
        For Each e In x
            With Workbooks.Add
                .SaveAs myDir & e & ".xlsx"
            End With
        Next
        fn = Dir(myDir & "*.xls")
        Do While fn <> ""
            Select Case True
                Case fn Like "EN.*", fn Like "FR.*", fn Like "ES.*"
                Case Else
                    With Workbooks.Open(myDir & fn).Sheets(1).Cells(1).CurrentRegion
                        .Parent.AutoFilterMode = False
                        For Each e In Array("EN", "FR", "ES")
                            .AutoFilter 1, e
                            If Workbooks(e & ".xlsx").Sheets(1).Cells(1) = "" Then
                                .Copy Workbooks(e & ".xlsx").Sheets(1).Cells(1)
                            Else
                                .Offset(1).Copy Workbooks(e & ".xlsx").Sheets(1).Range("a" & Rows.Count).End(xlUp)(2)
                            End If
                        Next
                        .Parent.Parent.Close False
                    End With
            End Select
            fn = Dir
        Loop
        For Each e In x
            Workbooks(e & ".xlsx").Close True
        Next
    End Sub
    I tested here and working.

  20. #20
    Registered User
    Join Date
    08-11-2014
    Location
    Luxembourg
    MS-Off Ver
    2010
    Posts
    11

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    For some reason it doesn´t work properly here. All 3 files I get after runnig the macro are completely empty

  21. #21
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Can you just run the code and the read msg if any comes up?
    Sub test()
        Dim myDir As String, fn As String, e, x
        With Application.FileDialog(msoFileDialogFolderPicker)
            If .Show Then myDir = .SelectedItems(1) & "\"
        End With
        If myDir = "" Then Exit Sub
        x = Array("EN", "FR", "ES")
        For Each e In x
            With Workbooks.Add
                .SaveAs myDir & e & ".xlsx"
            End With
        Next
        fn = Dir(myDir & "*.xls")
        If fn = "" Then MsgBox "No file found"
        Do While fn <> ""
            MsgBox fn
            Select Case True
                Case fn Like "EN.*", fn Like "FR.*", fn Like "ES.*"
                Case Else
                    With Workbooks.Open(myDir & fn).Sheets(1).Cells(1).CurrentRegion
                        .Parent.AutoFilterMode = False
                        For Each e In Array("EN", "FR", "ES")
                            .AutoFilter 1, e
                            If Workbooks(e & ".xlsx").Sheets(1).Cells(1) = "" Then
                                .Copy Workbooks(e & ".xlsx").Sheets(1).Cells(1)
                            Else
                                .Offset(1).Copy Workbooks(e & ".xlsx").Sheets(1).Range("a" & Rows.Count).End(xlUp)(2)
                            End If
                        Next
                        .Parent.Parent.Close False
                    End With
            End Select
            fn = Dir
        Loop
        For Each e In x
            Workbooks(e & ".xlsx").Close True
        Next
    End Sub

  22. #22
    Registered User
    Join Date
    08-11-2014
    Location
    Luxembourg
    MS-Off Ver
    2010
    Posts
    11

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    I´ve got the following messages:
    "ES.xlsx", "FR.xlsx", "EN.xlsx" and the files are empty as well

  23. #23
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    That means you have no excel file other than newly created files.

  24. #24
    Registered User
    Join Date
    08-11-2014
    Location
    Luxembourg
    MS-Off Ver
    2010
    Posts
    11

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    I wouldn´t be quite sure, cause I tried with both ways... with existing files namend "ES, "EN" and "FR" and without them and I´ve got the same message for both runnings.
    The information is not being "exported" into the 3 new files.

  25. #25
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Of course, there's no file to be processed according to the result of the messages.

    Just place your sample file "Table_Sample.xls" in the folder and rum the code then select that folder.

  26. #26
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    Duplicate............

  27. #27
    Registered User
    Join Date
    08-11-2014
    Location
    Luxembourg
    MS-Off Ver
    2010
    Posts
    11

    Re: Spliting up an excel spreadsheet with languages' rows into multiple files

    I finally could use it!!! Thanks a lot and above all for your patience with me!!!

+ 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. [SOLVED] Can I split up an excel spreadsheet into multiple files by rows?
    By seespot in forum Excel General
    Replies: 14
    Last Post: 08-28-2017, 04:36 PM
  2. How can I get excel to display multiple languages.
    By Colin.Matthews in forum Excel General
    Replies: 1
    Last Post: 04-09-2014, 06:37 AM
  3. Spliting cell data into multiple new rows - question on solved post
    By ExcelNewbie1108 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-09-2011, 05:56 PM
  4. MS Excel Multiple Files into Spreadsheet
    By jaym911 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-25-2011, 09:08 PM
  5. Read unicode (Asian Languages) from Excel spreadsheet
    By Frank in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-02-2005, 11:07 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