Тёмный

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

Jie Jenn
Подписаться 64 тыс.
Просмотров 101 тыс.
50% 1

Опубликовано:

 

29 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 196   
@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 ☕.
@mes1812
@mes1812 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?
@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?
@fatimasantillan4198
@fatimasantillan4198 3 года назад
What is the category name? Is it the. States in this examples?
@tamaradissanayake5552
@tamaradissanayake5552 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 2 года назад
me too, can anyone help us understand what's the reason?
@hoangkhai2673
@hoangkhai2673 Год назад
Same here :( Any recommendation how to solve it? Thanks a lot!
@ianjones9820
@ianjones9820 Год назад
Same issue. Any ideas?
@nihadalbibani
@nihadalbibani Год назад
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?
@balveersingh01
@balveersingh01 2 года назад
Heyy Jie, Thanks a lot . This is so simple to understand and saved me a lot of time . More power to you...
@leotos5395
@leotos5395 3 года назад
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... :(
@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
@adhyayana99
@adhyayana99 Год назад
hi, I have an excel with 2 sheets, am unable to split them into separate workbooks. If you could help please
@Jheinsmith
@Jheinsmith 3 месяца назад
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
@hanifsanatkhani4587
@hanifsanatkhani4587 3 года назад
Well Thank you so much for a good explanation mate.
@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
@pongepongstan8637
@pongepongstan8637 Год назад
Hi I tried to run the macro but my excel suddenly close
@vijaysridhar9063
@vijaysridhar9063 2 года назад
I have tried this, one file only generated. Error I am getting it
@KeithDavid-r6t
@KeithDavid-r6t 3 месяца назад
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 3 месяца назад
Hard to tell without looking at your entire code.
@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")
@sandrac.731
@sandrac.731 3 года назад
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.
@weixue1113
@weixue1113 7 месяцев назад
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"?
@tejasvirao8551
@tejasvirao8551 10 месяцев назад
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
@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!!!
@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.
@mfarhanahussain633
@mfarhanahussain633 9 месяцев назад
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 )
@Light.9
@Light.9 2 года назад
What about if my main Excel file having multiple sheets? How to modify the Macro?
@suki9860
@suki9860 2 года назад
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 года назад
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.
@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?
@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
@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
@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?
@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 ❤
@TimWilliams-z8q
@TimWilliams-z8q Год назад
Thank you very much Jie. Is there a way to incorporate .AutoFit into this VBA string for the output worksheets?
@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?
@vishnudev1435
@vishnudev1435 Год назад
Hi, can we split a an excel file file which having two row column heading? can you help me to write the code..plz
@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?
@k.k.sabariraj6484
@k.k.sabariraj6484 2 года назад
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
@1906931
@1906931 4 месяца назад
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 4 месяца назад
That's a little more complex not something I can explain in a comment.
@1906931
@1906931 4 месяца назад
@@jiejenn I know. I have been trying to find a way but no help. Would using. PasteSpecial XL column width work?
@anamjalil9908
@anamjalil9908 Год назад
Dear Jie, I am big fan of your videos and you are truly life saver... however, I wanted to share the excel with you. Can you please help me out in it. I want segregartion of data City wise along with score care without removing formula. Could you please share your email please.
@anamjalil9908
@anamjalil9908 Год назад
Still waiting for your kind response
@dumitracheflorin-daniel8605
@dumitracheflorin-daniel8605 5 месяцев назад
Hello! what if i want to save the files in utf-8 csv?
@jiejenn
@jiejenn 5 месяцев назад
You can sue the encoding parameter.
@edward_lee
@edward_lee 3 года назад
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.
@muhammadfahadazamjamil8045
@muhammadfahadazamjamil8045 Год назад
Thank you so much for the detailed video you're the best.
@celiomansini
@celiomansini 4 года назад
You have saved my life! Enjoy your coffee. Best regards from Rio de Janeiro!
@jiejenn
@jiejenn 4 года назад
Thanks! And glad my video helped.
@nikhilnarkhede3774
@nikhilnarkhede3774 3 года назад
Anyone can help me i have to give file name more than 31 char. how to do it??
@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!
@fishfoot123
@fishfoot123 2 года назад
Really helpful... Thank you very much
@AnthonyCollins-h1y
@AnthonyCollins-h1y Год назад
Thanks mate, i have 300,000 rows of data and ended up with 181 files, life saver.
@khangnguyen-ul6ou
@khangnguyen-ul6ou Год назад
Amazing.. It is so good but I can't do it
@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.
@detdet1302
@detdet1302 2 года назад
You are awesome you saved me :)
@somyaraiwani7938
@somyaraiwani7938 3 года назад
I want to know how many references you used in this code?
@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.
@alicemorili1330
@alicemorili1330 3 года назад
Great video. How can I add some text at top of each new worksheet and start the list below that text?
@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.
@NoRickenbackers
@NoRickenbackers Год назад
Amazing-thanks!
@NavinSinghFartyal
@NavinSinghFartyal Год назад
you did great job
@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.
@edmel9072
@edmel9072 3 года назад
how to update the data file if i add new data files.?
@xiangwenqiu9330
@xiangwenqiu9330 4 года назад
how to save all split files in different location? Please help:)
@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.
@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 года назад
I don't see any problem with that.
@isbisb
@isbisb Год назад
nice , thanks
@w.y.2443
@w.y.2443 3 года назад
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 3 года назад
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.
@chrisparrott5158
@chrisparrott5158 2 года назад
This is awesome!
@gohclarissa
@gohclarissa 2 года назад
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 2 года назад
This is actually something I'm looking into it currently. Will give an update once I have something to show for.
@yordanfy
@yordanfy 2 года назад
Thank you so much for teach us this awesome script. Awesome!!!
@jiejenn
@jiejenn 2 года назад
Glad the video help.
@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 :)
@DanielGarcia-nk8bt
@DanielGarcia-nk8bt 2 года назад
Thank you for the tutorial... is there a way to split this by including cells with formulas?
@jiejenn
@jiejenn 2 года назад
Interesting question. Let me look into 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 года назад
Change constant to a regular variable, then you should be able to use an inputbox.
@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?
@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.
@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 RU-vid@LearnDataAnalysis.org and I can take a quick look.
@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 Год назад
@@jiejenn Hey I'm getting same error. .AutoFilter .Range("D1").Column, Category_Name
@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 Год назад
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.
@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.
@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.
@bmwme4689
@bmwme4689 Год назад
did you solve it?
@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.
@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 года назад
One approach is to delete the unwanted columns after you export a report.
@JerryMinor001
@JerryMinor001 2 года назад
This as a big help to me. Thank you so much!
@jiejenn
@jiejenn 2 года назад
Glad the video helped.
@alansandusky94
@alansandusky94 3 года назад
very helpful - thank you.
@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
@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!!
@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!
@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
@undrawingend
@undrawingend 3 года назад
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 года назад
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.
@arditiljazi6959
@arditiljazi6959 Год назад
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 Год назад
That's out the scope of this tutorial, perhaps in the future.
@arditiljazi6959
@arditiljazi6959 Год назад
@@jiejenn is this something you could for me privately?
@jiejenn
@jiejenn Год назад
@@arditiljazi6959 Send me the detail to youtube@learndataanalysis.org on what you are trying to do.
@arditiljazi6959
@arditiljazi6959 Год назад
@@jiejenn I have sent you an email. Thank you
@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 года назад
@@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?
@beitsbe
@beitsbe 2 года назад
Thank you! this was so simple to follow and saved me so much time!
@jiejenn
@jiejenn 2 года назад
Glad the video helped.
@vaardanchennupati4534
@vaardanchennupati4534 4 года назад
Hi Please help i am getting any error "Run time error '9' subscript out of range"
@vaardanchennupati4534
@vaardanchennupati4534 4 года назад
Figured it out thank you for the video it really helped me a lot.
@priscillaspencer7759
@priscillaspencer7759 2 года назад
Hi! Do you remember how you fixed it? I need help lol
@nengtech6914
@nengtech6914 4 года назад
Very nice tip
@tristanlee5612
@tristanlee5612 3 года назад
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 3 года назад
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 RU-vid@LearnDataAnalysis.org
@tristanlee5612
@tristanlee5612 3 года назад
@@jiejenn Thanks Jie, just emailed, please kindly check and let me know ! thank you for the prompt reply
@jiejenn
@jiejenn 3 года назад
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 3 года назад
@@jiejenn Thank you so much Jie for this in advance
@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 года назад
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 3 года назад
@@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.😣
@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 RU-vid@LearnDataAnalysis.org and I can take a look when I get a chance.
@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 :)
@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 3 года назад
@@vinayakjituri9210 How did you solve it? I am also stuck in line 96
@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 года назад
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 Год назад
@@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?
@yashgokhale9332
@yashgokhale9332 4 года назад
You are a life saver. This saved me a lot of precious hours of manual work! Thank you.
@raiderpak1
@raiderpak1 3 года назад
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 3 года назад
Sorry about the late reply. The process is a bit more complicated if you have multiple tables on a single sheet.
@raiderpak1
@raiderpak1 3 года назад
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?
@មើលប្រដាល់-យ3ស
I'm run error
@jiejenn
@jiejenn 3 года назад
Ok.
@មើលប្រដាល់-យ3ស
@@jiejenn Can you make more videos of the solution? wbTarget.SaveAs Target_Folder & Category_Name & ".xlsx", 51 (Error)
@Zenduri
@Zenduri 4 года назад
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/
@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 ?
Далее
Excel Macros & VBA - Tutorial for Beginners
50:20
Просмотров 1,2 млн
ДЕНЬ УЧИТЕЛЯ В ШКОЛЕ
01:00
Просмотров 1,4 млн
EASILY Make an Automated Data Entry Form in Excel
14:52
VBA: Split data into Separate Workbooks
11:25
Просмотров 104 тыс.
Split Excel Data into Multiple Sheets Automatically
9:57