How to split an Excel file into multiple files using VBA | Excel Automation

Поділитися
Вставка
  • Опубліковано 15 січ 2025

КОМЕНТАРІ • 196

  • @sandrac.731
    @sandrac.731 3 роки тому +1

    We got a 17 000 lines ticket sales database to split in my company, your tutorial saved us DAYS of tedious work !! I don't know how to thanks you enough !!!

    • @jiejenn
      @jiejenn  3 роки тому

      Glad my video helped. You can always buy me a coffee using the link in the description.

  • @AnthonyCollins-h1y
    @AnthonyCollins-h1y Рік тому

    Thanks mate, i have 300,000 rows of data and ended up with 181 files, life saver.

  • @celiomansini
    @celiomansini 4 роки тому +1

    You have saved my life! Enjoy your coffee. Best regards from Rio de Janeiro!

    • @jiejenn
      @jiejenn  4 роки тому +1

      Thanks! And glad my video helped.

  • @MK02599
    @MK02599 2 роки тому

    You saved me... Before using this macro, I have spent 1 month for split and merge huge excel files. Thank you so much!! Please enjoy coffee from me 😉

    • @jiejenn
      @jiejenn  2 роки тому

      Cool. Glad my video helped! And thanks for the ☕.

  • @balveersingh01
    @balveersingh01 2 роки тому +2

    Heyy Jie, Thanks a lot .
    This is so simple to understand and saved me a lot of time .
    More power to you...

  • @edward_lee
    @edward_lee 3 роки тому +1

    Thank you, sir! This VBA was a life saver for something I needed to get done by today!

    • @jiejenn
      @jiejenn  3 роки тому

      Glad my video helped. And thanks for the coffee.

  • @hanifsanatkhani4587
    @hanifsanatkhani4587 3 роки тому +1

    Well Thank you so much for a good explanation mate.

  • @yashgokhale9332
    @yashgokhale9332 4 роки тому +2

    You are a life saver. This saved me a lot of precious hours of manual work! Thank you.

  • @NavinSinghFartyal
    @NavinSinghFartyal 2 роки тому

    you did great job

  • @Omshanthiom9
    @Omshanthiom9 2 роки тому

    Really helpful... Thank you very much

  • @yordanfy
    @yordanfy 3 роки тому

    Thank you so much for teach us this awesome script. Awesome!!!

    • @jiejenn
      @jiejenn  3 роки тому

      Glad the video help.

  • @beitsbe
    @beitsbe 3 роки тому

    Thank you! this was so simple to follow and saved me so much time!

    • @jiejenn
      @jiejenn  3 роки тому

      Glad the video helped.

  • @nihadalbibani
    @nihadalbibani 2 роки тому +1

    Works great for me, however if I have other tabs in the file can those tabs be copied including the formulas in those tabs?, also can I keep the name of the tab to stay Registered_Business_Locations_- in the new files?

  • @JerryMinor001
    @JerryMinor001 3 роки тому

    This as a big help to me. Thank you so much!

    • @jiejenn
      @jiejenn  3 роки тому

      Glad the video helped.

  • @detdet1302
    @detdet1302 2 роки тому

    You are awesome you saved me :)

  • @vanshikagupta3597
    @vanshikagupta3597 Рік тому

    Hi, Thank you for this amazing solution. But, I am facing an issue here.
    At 18:30 time of your video, where you run and then verify the unique count - I am getting 0 (I am expecting a number like 152).
    Please help!!!

  • @tamaradissanayake5552
    @tamaradissanayake5552 3 роки тому +2

    I am getting an error with this text string. Any advise? I also downloaded your workfiles to test and it was the same.
    col.Add .Cells(RowNumber, "A").Value, CStr(.Cells(RowNumber, "A").Value)
    Next RowNumber

    • @chapatrux
      @chapatrux 3 роки тому +2

      me too, can anyone help us understand what's the reason?

    • @hoangkhai2673
      @hoangkhai2673 Рік тому +1

      Same here :( Any recommendation how to solve it? Thanks a lot!

    • @ianjones9820
      @ianjones9820 Рік тому

      Same issue. Any ideas?

  • @NoRickenbackers
    @NoRickenbackers Рік тому

    Amazing-thanks!

  • @TimWilliams-z8q
    @TimWilliams-z8q Рік тому

    Thank you very much Jie. Is there a way to incorporate .AutoFit into this VBA string for the output worksheets?

  • @chrisparrott5158
    @chrisparrott5158 2 роки тому

    This is awesome!

  • @alansandusky94
    @alansandusky94 4 роки тому

    very helpful - thank you.

  • @isbisb
    @isbisb Рік тому

    nice , thanks

  • @mes1812
    @mes1812 2 роки тому +2

    What would I write so that my output files names are saved like such as
    Test_CA_Version1.xlsx
    Where "Test" and "Version" are manual inputs into another field on a second worksheet?

  • @nengtech6914
    @nengtech6914 4 роки тому

    Very nice tip

  • @justinaustin5130
    @justinaustin5130 Рік тому

    Thank you! The macro works perfectly until it hits a category name with a slash. Is there any way to get this to read this as 1 thing?

    • @jiejenn
      @jiejenn  Рік тому

      One approach is to replace the special characters before you start splitting the files. Otherwise, you will have to create a function to replace the special characters in the script.

  • @weixue1113
    @weixue1113 11 місяців тому

    Hi, your video is really helpful! one quick question regarding the autofilter, what if I need to set up my filter on the second row of Column A, should I put ".AutoFilter .Range("A2").Column, Category_Name"?

  • @1906931
    @1906931 7 місяців тому

    Everything works fine. However, i would want the new workbooks created to have same column width as the source sheet. How do i do that ?

    • @jiejenn
      @jiejenn  7 місяців тому

      That's a little more complex not something I can explain in a comment.

    • @1906931
      @1906931 7 місяців тому

      @@jiejenn I know. I have been trying to find a way but no help. Would using. PasteSpecial XL column width work?

  • @alicemorili1330
    @alicemorili1330 3 роки тому

    Great video. How can I add some text at top of each new worksheet and start the list below that text?

  • @Jheinsmith
    @Jheinsmith 6 місяців тому

    I have to do this every week but with new data that I get every week. How can I use this macro to work in other excel files using the same criteria

  • @ibbaraibbara
    @ibbaraibbara Рік тому

    Hello jie, thanks a lot on this.
    How can i add a header, use a longer names like insead of states i used company name which is more character. Thank you ❤

  • @mfarhanahussain633
    @mfarhanahussain633 Рік тому

    Hi jie, do you have any tutorial where an excel file of 15k rows can be split into multiple excels respective to row counts ( like split in batches of 600 )

  • @adhyayana99
    @adhyayana99 Рік тому

    hi, I have an excel with 2 sheets, am unable to split them into separate workbooks. If you could help please

  • @marcellaclara2683
    @marcellaclara2683 2 роки тому

    Thank you! It's really inspiring. I want to try it. Could you tell me if it's okay that the first row is only header with no content?

    • @jiejenn
      @jiejenn  2 роки тому +1

      I don't see any problem with that.

  • @catalinarose8519
    @catalinarose8519 Рік тому

    hi. This is great, life saver. One question. How to I change the OUTPUT folder
    Like where you have Const Target_Folder As String = "C\:...." I want to insert in the excel file, let's say a new sheet and write in cell D4 the path: C:\Users\etc
    what to I write?

    • @jiejenn
      @jiejenn  Рік тому

      You can use the range method. For example range ("d4")

  • @albanbytyqi4973
    @albanbytyqi4973 2 роки тому

    Thank you. For some reason the video is very blurred and I cannot make out the content displayed. I wonder if this my problem or it is a problem for other viewers?

  • @naturerelaxing3850
    @naturerelaxing3850 2 роки тому

    Hi Jie, thanks for sharing this. Really appreciate it. How can we keep the same column width on our split files? Thanks

    • @jiejenn
      @jiejenn  2 роки тому

      One approach is you can use the copy past special method to just paste the column width to set the column width to match the original tile.

    • @naturerelaxing3850
      @naturerelaxing3850 2 роки тому

      @@jiejenn thank you for the prompt reply. I really appreciated and it worked.

  • @DanielGarcia-nk8bt
    @DanielGarcia-nk8bt 3 роки тому

    Thank you for the tutorial... is there a way to split this by including cells with formulas?

    • @jiejenn
      @jiejenn  3 роки тому

      Interesting question. Let me look into it.

  • @leotos5395
    @leotos5395 3 роки тому +1

    Hello! What if I have a table? Seems like its not functioning if you have to maintain a table format.. :( otherwise it would be perfect... :(

  • @tejasvirao8551
    @tejasvirao8551 Рік тому

    Hello !!! Thank you for this tutorial. It was really helpful.
    I was able to split the data into different workbooks but when giving the Saveas command, I do not find the variables Save or Saveas. I only see SavedasArray. Can you help me how to define the variable Save and SaveAs ?
    Maybe due this I'm seeing the error Method 'Add' o object 'Workbooks' failed.
    Please help

  • @suki9860
    @suki9860 2 роки тому +1

    Jie, Thank you for an excellent presentation of this functionality. Sharing your thought processes as you build the code is an absolutely perfect learning experience for all of us newbies! I have a question about the SavingAs message popping up as each file is saved. Is there a way to suppress these messages so that it is a smooth user experience. You put in Application. DisplayAlerts = False to achieve this but the message still appears. I also added in ScreenUpdating = False and EnableEvents = False but the message still pops up. Any help with this? Thanks again.

    • @jiejenn
      @jiejenn  2 роки тому +1

      Hum... To be honest, I can't figure out why it isn't working. I will have to look at the files to really investigate the issue.

  • @harkunsith8815
    @harkunsith8815 2 роки тому

    could you please also show how to email each file to respectively email ids?

    • @jiejenn
      @jiejenn  2 роки тому

      I'll look into it.

  • @fatimasantillan4198
    @fatimasantillan4198 3 роки тому

    What is the category name? Is it the. States in this examples?

  • @districtaccountsofficer8812
    @districtaccountsofficer8812 2 роки тому

    Dear, what if the output is required in pdf format instead of xlsx. Please let me know

    • @jiejenn
      @jiejenn  2 роки тому

      You save as a PDF file.

  • @dumitracheflorin-daniel8605
    @dumitracheflorin-daniel8605 9 місяців тому

    Hello! what if i want to save the files in utf-8 csv?

    • @jiejenn
      @jiejenn  9 місяців тому

      You can sue the encoding parameter.

  • @vishnudev1435
    @vishnudev1435 2 роки тому

    Hi, can we split a an excel file file which having two row column heading? can you help me to write the code..plz

  • @dallasxal
    @dallasxal Рік тому

    I tried it and it is creating each separate file but all files contain the all data. It is as if it is copy pastying all data and not only data from Filtered category value

  • @Light.9
    @Light.9 2 роки тому

    What about if my main Excel file having multiple sheets? How to modify the Macro?

  • @irsjadadjani489
    @irsjadadjani489 Рік тому

    this is a huge help. but i need to split them by Ownership Name. sometimes there are names that are longer than 31 characters. How to circumnavigate this?

  • @somyaraiwani7938
    @somyaraiwani7938 3 роки тому

    I want to know how many references you used in this code?

  • @msdyzuniga
    @msdyzuniga 4 роки тому

    This is such a lifesaver! 🙏
    I was wondering if there was a way to also have the macro password protect the file based on cell in the worksheet?

  • @Zaheem4u
    @Zaheem4u 2 роки тому

    Hello.... Thank you...
    Files are splitted into multiple files but the width of the Column is same in All files whereas in Original file, Size of the Column is different.
    Also filter is not applied to the splitted files whereas filter is applied in Original File.
    Any solution to fix it

  • @szon9115
    @szon9115 2 роки тому

    Hey Jie, great code. I have one question though - is there a way I can base the target folder on user's input? How could I do that? Since you coded it as constant, I can not add InputBox to it...

    • @jiejenn
      @jiejenn  2 роки тому +2

      Change constant to a regular variable, then you should be able to use an inputbox.

  • @rashhours
    @rashhours Рік тому

    Hi Jie, do you have any tutorial where Excel file (with multiple sheets) is split into multiple files? Example there is Sheet 1 for Costs, Sheet 2 for Sales, and I want to split data of these sheets (costs and sales) using unique code (example company codes 1, 2 & 3) - so that when it splits, the files for each company code will contain both the sheet for Costs and the sheet for Sales showing only their figures. Thanks!

  • @vijaysridhar9063
    @vijaysridhar9063 2 роки тому

    I have tried this, one file only generated. Error I am getting it

  • @siddharthtulsyan8405
    @siddharthtulsyan8405 Рік тому

    Hi! I am trying this, however getting compile error as “Variable Not Defined” for SetCollectionUniqueList. Please help.

    • @jiejenn
      @jiejenn  Рік тому

      Did you declare the object?

  • @JONNEYBANSAL
    @JONNEYBANSAL Рік тому

    Hey I am not able to do it in Macbook, could you please tell me how I can do it its showing 1004 Error

  • @pongepongstan8637
    @pongepongstan8637 Рік тому

    Hi I tried to run the macro but my excel suddenly close

  • @emilymida7755
    @emilymida7755 3 роки тому

    This works great! But I need one optimization - how can I have it also copy over my header and footer?

    • @jiejenn
      @jiejenn  3 роки тому

      Copying header and footer requiring a separate macro to handle the procedure individually.

  • @sacank1
    @sacank1 2 роки тому

    Great job explaining this, Jie! Is there a way to exclude some columns from being pasted into the split files? For example, if I only want columns F:AR to be pasted into the output files.

    • @jiejenn
      @jiejenn  2 роки тому +1

      One approach is to delete the unwanted columns after you export a report.

  • @gohclarissa
    @gohclarissa 3 роки тому

    Hello Jie, how can i retain the formulas in the file so that the equations are still there after the file split? The “paste” function does not seem to cover formulas.

    • @jiejenn
      @jiejenn  3 роки тому +1

      This is actually something I'm looking into it currently. Will give an update once I have something to show for.

  • @khangnguyen-ul6ou
    @khangnguyen-ul6ou 2 роки тому

    Amazing.. It is so good but I can't do it

  • @raiderpak1
    @raiderpak1 4 роки тому

    Thanks for this video it worked perfectly! How can i do this if i have multiple data sets on multiple sheets that need to be split into individual files?

    • @jiejenn
      @jiejenn  4 роки тому

      Sorry about the late reply. The process is a bit more complicated if you have multiple tables on a single sheet.

    • @raiderpak1
      @raiderpak1 4 роки тому +1

      No problem thanks! I figured it out creating a different script. Appreciate the help!!

    • @anushajayanth2388
      @anushajayanth2388 2 роки тому

      @@raiderpak1 Hi...could you please let me know how you did that?

  • @Ohmwreckerr
    @Ohmwreckerr Рік тому

    This tutorial is totally relevant to what I'm working right know, I've already tried the code and it's working base on what I've want, however the only error I've encountered is that if the naming of the file is exceeding my 31 characters how can I resolve this error Champ?

  • @evaaljancic
    @evaaljancic 2 роки тому

    Hi Jie,
    this tutorial and VBA code is life changing. Thank you very much for that! However I would desperately need one more modification, which I have no clue how to do it. Would you be so kind to provide me guidance on how to change code if you have “header” that consists of 10 rows. My data starts at row 11, however, in each split file I would like to keep all the header data from row 1-10. Thank you!

    • @jiejenn
      @jiejenn  2 роки тому

      Hi Eva, giving the number of request I receive each day, I now charge $10 service fee for any support.

    • @vedhikha04
      @vedhikha04 Рік тому

      Hi Eva - I need the same help. My header is 13 rows. How did you solve this? Please help!!

  • @dianara7658
    @dianara7658 2 роки тому

    Thank you so much for this video. I believe I'm close to completing this macro but I got an "type mismatch" error for this line " If Len(Trim(.Range("A1").Value)) > 0 Then " any advise on how to solve it? Thank you for your support

    • @jiejenn
      @jiejenn  2 роки тому

      Check for typos in your script.

    • @dhankad10
      @dhankad10 2 роки тому

      I was getting the same error. turned out there was a cell with 'vlookup' in the masterdata tab which made A1 cell of 'helper' tab a reference value, thereby throwing same error as you mentioned.

  • @christinajani1672
    @christinajani1672 3 роки тому

    Hello! I am trying to keep the data validation, is it possible?

    • @jiejenn
      @jiejenn  3 роки тому

      It's possible. If you want to preserve all the settings from the master file, you will need to make a copy of the original file, then filter the data on the copied workbook.

  • @k.k.sabariraj6484
    @k.k.sabariraj6484 3 роки тому

    thks , here I need file save in binary format(. xlsb ) how to re_write code

  • @bimal84mehta
    @bimal84mehta 3 роки тому

    This was helpful. However i have another request and don't know how do it.. I have a file with 10k records and want to split this file with 25 records in each file but keep the headers in for each file

  • @Cefeusz
    @Cefeusz 4 роки тому

    Hi, this is excellent, but what if I have 3 worksheets, splitting only first one and copy rest worksheets to the new files ?

    • @chriskeane6366
      @chriskeane6366 2 роки тому

      did you ever figure this out? trying to do the same thing

  • @orlaghquinn3044
    @orlaghquinn3044 4 роки тому

    Hi Jie, I'm trying to split a huge file into country specific files, I have used you code which is great and does almost everything that I need. Only it copies all 25000 rows and not just the 10-2000 country specific that I need. Any suggestions?

    • @jiejenn
      @jiejenn  4 роки тому

      Not sure if I follow. Do you know the macro is not looping through all the country? Or the macro is not copying the filtered dataset?

    • @orlaghquinn3044
      @orlaghquinn3044 4 роки тому

      @@jiejenn I'm getting all the country files but its every single record, it looks like it hasn't filtered.

    • @jiejenn
      @jiejenn  4 роки тому

      Probably a typo somewhere along the script. If you want, you can send me your file to UA-cam@LearnDataAnalysis.org and I can take a look when I get a chance.

  • @undrawingend
    @undrawingend 4 роки тому

    Just tried this for a consolidation list and it’s not bringing through anything - it’s making the files but not bringing across the data needed any help ?
    Sorry managed to fix this issue - is it possible to have this save into a different file path each time ? Eg by date so work I did today gets placed into today’s date and each date going forward

    • @edschneider5533
      @edschneider5533 3 роки тому +1

      Hey I'm having the same issue, how did you fix it? Its created the separate files but no data is coming through, just the headers. Any help is appreciated. Thanks man

    • @undrawingend
      @undrawingend 3 роки тому

      @@edschneider5533 I had to double check the VBA code for data location- in data given it’s taking it from column G I was needing column C - simple error to make - if still having issues just reply

    • @edschneider5533
      @edschneider5533 3 роки тому

      @@undrawingend Thanks for replying, I'm using the right column to split just weird its not pulling any of the data from the table, just the headers. Wondering if it's because I'm using Microsoft 365, not sure if VBA format would be different.

  • @SMS_Reminds_us
    @SMS_Reminds_us 13 днів тому

    Hi Jie Jenn ,
    I was Getting a RunTime Error:1004 , While using this code !!

  • @arditiljazi6959
    @arditiljazi6959 2 роки тому

    hi, instead of splitting the table into separate files, could you show how to email them automatically as an attachment . for example, , every id in column A1 ( location id) will be linked to an email address on another sheet and when you start the macro, every row that contains id 1234 in location Id will separate into its own file as an attachment.

    • @jiejenn
      @jiejenn  2 роки тому

      That's out the scope of this tutorial, perhaps in the future.

    • @arditiljazi6959
      @arditiljazi6959 2 роки тому

      @@jiejenn is this something you could for me privately?

    • @jiejenn
      @jiejenn  2 роки тому

      @@arditiljazi6959 Send me the detail to youtube@learndataanalysis.org on what you are trying to do.

    • @arditiljazi6959
      @arditiljazi6959 2 роки тому

      @@jiejenn I have sent you an email. Thank you

  • @KeithDavid-r6t
    @KeithDavid-r6t 6 місяців тому

    If you want to save the files as CSV vs xlsx is that possible? I tried playing with the code and changed the line.
    Application.ActiveWorkbook.SaveAs Filename:=FPath & "\" & ws.Name & ".xlsx"
    To:
    Application.ActiveWorkbook.SaveAs Filename:=FPath & "\" & ws.Name & ".csv"
    but it doesn't populate the sheets until I change it back to xlsx and run that again. After it populates both the csv and xlsx files.
    I was hoping there was a way to make it populate the csv without having the run the program twice.

    • @jiejenn
      @jiejenn  6 місяців тому

      Hard to tell without looking at your entire code.

  • @edmel9072
    @edmel9072 4 роки тому

    how to update the data file if i add new data files.?

  • @ellenzpunter
    @ellenzpunter 4 роки тому

    Hi Jie - Thank you for this video! Very helpful :) I hope you enjoy a coffee from me. I have one question - if I would like to split the file but only create new files for a few selected states, where within the code could I apply this change?

    • @jiejenn
      @jiejenn  4 роки тому

      Thanks for the coffee, much appreciated it. Regarding your follow up question, you want to make the change to line 34 to 36.
      To exclude categories, you will insert an IF condition (see below):
      For i = 1 To collectionUniqueList.Count
      ' collectionUniqueList.Item(i) --> returns the category name
      If Not (collectionUniqueList.Item(i) = "Category Name X" Or collectionUniqueList.Item(i) = "Category Name Y") Then
      SplitWorksheet (collectionUniqueList.Item(i))
      End If
      Next i
      To produce output files to just specific categories:
      For i = 1 To collectionUniqueList.Count
      ' collectionUniqueList.Item(i) --> returns the category name
      If collectionUniqueList.Item(i) = "Category Name X" Or collectionUniqueList.Item(i) = "Category Name Y" Then
      SplitWorksheet (collectionUniqueList.Item(i))
      End If
      Next i

    • @ellenzpunter
      @ellenzpunter 4 роки тому

      @@jiejenn Perfect!! Thanks so much :)

  • @eduardanunes9944
    @eduardanunes9944 4 роки тому

    I've been trying to use this code and it looks like it is splitting correctly, but when I open the sliced files they are not filtered by the unique values in the column I selected (even though the macro generated all files with the correct names from the column I need). How can I fix that?

    • @jiejenn
      @jiejenn  4 роки тому

      Send to your file to UA-cam@LearnDataAnalysis.org and I can take a quick look.

  • @iMadeDreamz
    @iMadeDreamz 2 роки тому

    Hi Jie, This is great. You saved me making 800 files. However, do you know if I could protect each file with a separate password for each?

    • @jiejenn
      @jiejenn  2 роки тому

      It is definitely possible. I guess the first question is where are you going to store the password?

    • @iMadeDreamz
      @iMadeDreamz 2 роки тому

      @@jiejenn On previous files I have saved them on a 'Very Hidden' tab and then it's looked up via a code (AA1 for example), Not sure if there is an easier way to do this?

    • @jiejenn
      @jiejenn  2 роки тому +1

      When you say lookup a code, do you mean you already have a VBA code to extract the password and apply to an Excel file? Not sure if I follow your statement there. Regardless, you will need to figure out where VBA need to fetch the password first.

    • @iMadeDreamz
      @iMadeDreamz 2 роки тому

      @@jiejenn Yeah, i already use some VBA to take a password and save/close a file using the password

    • @tl5769
      @tl5769 2 роки тому

      @@jiejenn Great Video! Love your work. Do you have a script which deals with the separate password or use the same password to be saved for all files created?

  • @goodmorning192
    @goodmorning192 3 роки тому

    Hi, I have about the size of 5 Gb CSV file, can we do the same without opening the file? Because opening the file takes up a lot of time and I want to save that time and do it efficiently.

  • @vinayakjituri9210
    @vinayakjituri9210 4 роки тому

    @Jie Jenn
    I am getting the error in the line 96 what i have to for that and its running 4-5 file and what is the mean of 51 here ?

    • @vinayakjituri9210
      @vinayakjituri9210 4 роки тому

      @Jie Jenn Problem solved Thank You

    • @NibuKoshy
      @NibuKoshy 4 роки тому

      @@vinayakjituri9210 How did you solve it? I am also stuck in line 96

  • @rajeshramesh3636
    @rajeshramesh3636 3 роки тому

    Question : In Macro file, when I split the excel and saving in .xlsx using Macro.
    But I want to save in Binary format .xlsb and I tried as well but it won't work for me...
    Pls guide me how to save binary format in Macro splits excel?

  • @subinuresh4762
    @subinuresh4762 3 роки тому

    Hey ! I am getting 1004 error code: Autofilter method of range class failed

    • @jiejenn
      @jiejenn  3 роки тому

      I will look into it.

    • @nihadalbibani
      @nihadalbibani 2 роки тому

      @@jiejenn Hey I'm getting same error. .AutoFilter .Range("D1").Column, Category_Name

  • @AmeliaVBall
    @AmeliaVBall 3 роки тому

    Hello. I get an error that says Run-time error '1004': Application defined or object-defined error. I copied your code exactly from the website and I even moved the column I wanted to filter to G so I didn't have to change anything except for the target folder. Do you know what could be the issue?

    • @jiejenn
      @jiejenn  3 роки тому

      There is typo somewhere in your code. Object define error means VBA cannot find the correct reference to create an object.

  • @w.y.2443
    @w.y.2443 4 роки тому

    My file name (which in your case is the state) exceed 23 characters, the max allowed by excel. How can I solve it?

    • @jiejenn
      @jiejenn  4 роки тому

      Maybe you can use the left function to extract just the first N characters as the file. This is the restriction set by the file system, Excel cannot override the setting.

  • @beibeiilovu
    @beibeiilovu 3 роки тому

    Hello, I stock in
    With wsSource
    With .Range(.Cells(1, 1), .Cells(LR, LC))
    Can you please help to check and let me know where I put wrong?
    Thank you.

    • @jiejenn
      @jiejenn  3 роки тому

      Your syntax looks incorrect to me.

    • @beibeiilovu
      @beibeiilovu 3 роки тому

      @@jiejenn I used LR as lastrow and LC as lastcolumn. This video did help a lot, could you please let me know to fix it? Thank you.

    • @beibeiilovu
      @beibeiilovu 3 роки тому

      @@jiejenn I used your format but I stock in
      With wsSource
      .AutoFilterMode = False
      Did I miss anything?
      Thank you.

    • @jiejenn
      @jiejenn  3 роки тому +1

      @@beibeiilovu First, there should be an error message. Second, it is possible to debug without knowing what you typed in your code. My suggestion for you is to post your question on Stackover Flow for faster response.

    • @beibeiilovu
      @beibeiilovu 3 роки тому

      @@jiejenn Hi Jei, I don't know how to get Stackover Flow. But I have a question, if the name on the column G is longer hen a tab require or contain "/" t, what can we do?

  • @andre41184
    @andre41184 4 роки тому

    very odd... at 16: 54, when you do the debugging, in my version I get compile error for LastRow as Invalid qualifier and I can not understand why... I wrote the exact code along with you, spelling is the same.

    • @andre41184
      @andre41184 4 роки тому

      nevermind, solved it with some Google after all :) Thank you a lot! I adapted it to a database of my own. Now the next step for me would be to build a new code which will make all aproximately 49 files protected by a certain password. I guess it is possible :)

  • @frederikklaas6471
    @frederikklaas6471 2 роки тому

    Hi what do I need to change, wen my table does not start at 1,1 but 3,1 so A3 (header)
    I have got the same issue also 1004.
    Bug says it is: With .
    Range(.Cells(3, 1), .Cells(LastRow, LastColumn))
    .AutoFilter .Range("D3").Column, Category_Name
    The second row seems to be the mistake AutoFilter...

    • @frederikklaas6471
      @frederikklaas6471 2 роки тому

      You could also reach me on my Email or number if that would make things easier. Would be amazing if you could help, because the deadline is getting really close. Thank you very much in advance!!

    • @frederikklaas6471
      @frederikklaas6471 2 роки тому

      Also gave you an invite on LinkedIn :)

    • @frederikklaas6471
      @frederikklaas6471 2 роки тому

      I just need to keep it starting with A3 as it would not fit otherwise with the questionnaire that comes right behind the table. Cos that one needs subcategories …

    • @frederikklaas6471
      @frederikklaas6471 2 роки тому

      Which are placed in row 1&2

    • @marsto7513
      @marsto7513 Рік тому

      Did u ever solve this problem? my table starts from the second row (A2 header) but I still want to keep the first row in the new workbooks. If I delete the first row the code runs fine but if I leave the first row in it won't work

  • @xiangwenqiu9330
    @xiangwenqiu9330 4 роки тому

    how to save all split files in different location? Please help:)

  • @danweisberg9496
    @danweisberg9496 3 роки тому

    When I run the macro I get an error Run-time error 1004 - Method 'SaveAs' of object '_Workbook' failed. Debug takes me to this line of code: wbTarget.SaveAs Target_Folder & Category_Name & ".xlsx", 51.

    • @jiejenn
      @jiejenn  3 роки тому

      Makes sure your file name doesn't contain any invalid character.

  • @vaardanchennupati4534
    @vaardanchennupati4534 4 роки тому

    Hi Please help i am getting any error "Run time error '9' subscript out of range"

  • @ChompooSuwannapruk
    @ChompooSuwannapruk 4 роки тому

    Hi, If I would like to save all new files in original folder, what should I put here Const Target_Folder As String = ""?I've tried to add below but doesn't workDim FPath AS StringFPath = wbTarget.PathAny suggestion on this? Thanks!

    • @jiejenn
      @jiejenn  4 роки тому +1

      This code will returns the root directory Thisworkbook.path. If I understand your question correctly, you just need to assign Thisworkbook.path to Target_Folder variable.

    • @ChompooSuwannapruk
      @ChompooSuwannapruk 4 роки тому

      @@jiejenn Thanks!!! All your vdos are so useful. I learned a lot from this channel:)

    • @MuhammadIrfan-ng9lf
      @MuhammadIrfan-ng9lf 4 роки тому

      @@jiejenn Hi there, can you teach me how to assign Thisworkbook.Path to Target_Folder...I'm lost :(

    • @hassel3400
      @hassel3400 3 роки тому

      @@jiejenn I wasn't able to follow. I tried putting this but it didn't work.
      Const Target_Folder As String = "Target_Folder variable"
      Apologies for being a dummy.😣

  • @edschneider5533
    @edschneider5533 3 роки тому

    Hello, can anyone help me. It's splitting the files, but no data is being returned. The headers are the only thing I see when it splits it.

    • @TheMegaPelado
      @TheMegaPelado 3 роки тому

      I have the same problem, did you solve it?

    • @TheMegaPelado
      @TheMegaPelado 3 роки тому

      I've found a solution, although not very optimized. What happened to me was that the column I used to Filter values was outside the proviously defined Range on the wsSource sheet.
      This changed the expected Autofilter behaviour, and it "shifted" the column used to filter. I wanted to filter using column D but since my range actually started at column E, the autofilter shifted 4 places left and thought it should filter using column H (D+4)
      TL;DR from this point:
      I included the filter column (D, or cell "4,1") inside the range to copy successfully all contents, and then deleted the columns I didnt want to add in my final files.

  • @nikhilnarkhede3774
    @nikhilnarkhede3774 3 роки тому

    Anyone can help me i have to give file name more than 31 char. how to do it??

  • @robertwalters1632
    @robertwalters1632 2 роки тому

    Great code, but I am getting an error subscript out of range on "Set wsSource = ThisWorkbook.Worksheets("Combined")" I changed the code to match the name of my sheet and now I get this error. Thoughts? and how would I get it to ask me which column I want to use for my filtered column?

    • @jiejenn
      @jiejenn  2 роки тому

      Makes sure your work sheet name doesn't have spaces on both ends.

    • @robertwalters1632
      @robertwalters1632 2 роки тому

      @@jiejenn nope no spaces. I copied name of sheet into the code.

    • @jiejenn
      @jiejenn  2 роки тому +1

      Then I don't know. Hard to debug without looking at your code at this point.

    • @tammyng6611
      @tammyng6611 2 роки тому

      I have the same issue too. I redid this whole process 3 times with a new data set each time and I'll I type in was the word Data without spacing. I've looked up other videos too and they all have this same issue.

  • @jeaninescott9714
    @jeaninescott9714 3 роки тому

    Thank you so much for this tutorial. You are an excellent instructor! Enjoy a cup of coffee on me!

    • @jiejenn
      @jiejenn  3 роки тому

      Glad my video helped. And thank you for the coffee!

  • @BahadurAli
    @BahadurAli 2 роки тому

    Nice video , i have one Large CSV file holding 12 Million rows i want to split this CSV into multiple file each file will be 1 million record

  • @K.G.Ashish
    @K.G.Ashish Рік тому

    Thank you, helped a lot
    But i have one issue,
    Lets say its debtor aging and there is company name on top of the list.
    I want that company name to appear on all the excel file on top of the DATA.
    How to do then ?

  • @Zenduri
    @Zenduri 4 роки тому +1

    I've tried to get this down from your video exactly as is to get it working on my own set of data with the aim of amending it then to suit my needs but i cant get this to run. No compile errors but getting "Run-time error 1004, Application-defined or object defined error" and i have no idea where the problem is. Also you dont have link to your example document. Any help is appreciated

    • @jiejenn
      @jiejenn  4 роки тому

      1004 error usually indicating somewhere in your code, there is a typo somewhere.
      I added the finalized Excel file and source on my website you can access them @ learndataanalysis.org/how-to-split-an-excel-file-into-multiple-files-using-vba/

  • @មើលប្រដាល់-យ3ស

    I'm run error

  • @tristanlee5612
    @tristanlee5612 4 роки тому

    Thanks so much on this but my files is bit different where i need to split data by column C which is the date number, the issue is this will create issue to name the file cos the date contains "/" , hence my solution will be to create an extra column to mark the week no. and when auto- copy and paste, the macros will only copy the specific range of the columns only from Column B to the end to exclude column A where im going to use it as the name of each file. could you please help on it, 10 coffees will be given thanks!!
    RecordID Customer Week Beginning Week Ending Product Code Store Number Sold Qty SOH Qty SOO Qty
    AUPAD DRC 1/06/2020 7/06/2020 BOXGSW121D DRC_HO 2 15
    AUPAD DRC 1/06/2020 7/06/2020 BOXNW1200 DRC_HO 0 0
    etc...

    • @jiejenn
      @jiejenn  4 роки тому

      Hey Tristan,
      Can you email me your two Excel files one is before and the other file will show the result after a macro is applied.
      My email is UA-cam@LearnDataAnalysis.org

    • @tristanlee5612
      @tristanlee5612 4 роки тому

      @@jiejenn Thanks Jie, just emailed, please kindly check and let me know ! thank you for the prompt reply

    • @jiejenn
      @jiejenn  4 роки тому +1

      Got your email + attachments. I am working on something for a client, I will give em a look once later when I am done with my stuff.

    • @tristanlee5612
      @tristanlee5612 4 роки тому

      @@jiejenn Thank you so much Jie for this in advance