Excel macro to combine CSV files (Using Excel VBA)

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • In this Excel automation tutorial, I will show you how we can write a macro (using Excel VBA) to combine multiple CSV files.
    Imaging your boss asks you to combine 10 or 50 CSV files by the end of the day, and you only have couple hours left. If you are going to do this task manually, it will takes a few hours. However, if you can automate this task, then everything can be done in let's say 5 minutes.
    Source Code: learndataanaly...
    Buy Me a Coffee? Your support is much appreciated!
    ----------------------------------------------------------------------------------------------------------------
    PayPal Me: www.paypal.me/...
    Venmo: @Jie-Jenn
    📺 Also check out my 2nd channel Excel channel focus on sharing Excel tips: / @jjpowerbi
    Support my channel so I can continue making free contents
    ---------------------------------------------------------------------------------------------------------------
    Patreon: / jiejenn
    By shopping on Amazon → amzn.to/2JkGeMD
    More tutorial videos on my website → LearnDataAnaly...
    Business Inquiring: TH-cam@LearnDataAnalysis.org
    #ExcelVBA #MergeCSV #CombineCSV #ExcelAutomation

ความคิดเห็น • 12

  • @drujene
    @drujene 2 ปีที่แล้ว

    quiet simple, and useful...thx

  • @IcanCwhatUsay
    @IcanCwhatUsay ปีที่แล้ว +2

    The line data_sheet.Range("A1").CurrentRegion.RemoveDuplicates 1, xlNo isn't working correctly for me. Instead of removing duplicates, it removes everything after the first CSV that was imported. Any Idea why?

    • @jiejenn
      @jiejenn  ปีที่แล้ว +1

      It is hard to tell without looking at your table.

  • @tj4362
    @tj4362 3 ปีที่แล้ว

    Thanks Jie! I'm a beginner with Visual. My question is if I add additional CSV files to the folder, do I run the macro again to add the new CSV info? Will it duplicate the files I already merged into the Excel worksheet?

    • @jiejenn
      @jiejenn  3 ปีที่แล้ว

      The same files will get overwritten.

  • @markamadeus4580
    @markamadeus4580 2 ปีที่แล้ว

    Hi Jie, can you change the delimiter in VBA from , to ;?

  • @rachelhoams8776
    @rachelhoams8776 3 ปีที่แล้ว

    Hi Jie, how can you use this macro but also have it add a column with the name of each CSV file you combined?

    • @jiejenn
      @jiejenn  3 ปีที่แล้ว

      Depending on what you want to drink. Basically you will have to write additional VBA code to perform the additional things you want to perform.

  • @ochirgereltbyambasuren9676
    @ochirgereltbyambasuren9676 ปีที่แล้ว

    Csv files not found comes out what should i do? Please help me

    • @jiejenn
      @jiejenn  ปีที่แล้ว

      Makes sure the file path you provided is correct.

    • @ochirgereltbyambasuren9676
      @ochirgereltbyambasuren9676 ปีที่แล้ว

      @@jiejenn Thanks it works. Is it possible to add code that change date format and replace the loss data to empty cell?

  • @namanjain3079
    @namanjain3079 2 ปีที่แล้ว +2

    Hey, why do i get Subscript out of range? Can you please help? on this
    Set data_sheet = ThisWorkbook.Worksheets("Master")