Merge two table from different csv files

Soly_90

New Member
Joined
Sep 4, 2024
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Hello ,
I am still beginner in using macro vba and I need a help .
I have two different csv file .
I want the user to enter the path file of the csv file to use as input in the script
This csv file has only one sheet called data ,that include one table with different columns .

The second csv file contains sheet called source
,include only one table .

I want to merge this table from first csv file with the table from the second csv file .

(first csv file (user input ) contains always column called target and the second csv file contains also target column )
Both of them has target column name
I need only to merge the rows that contains same value in target column and ignore the rest rows .


I would like to have like window ,that allow user to enter the file path of excel file and also the user enter folder path of csv file
And button to run the script

Could you help me ?
Thanks in advance
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I would use Power Query and Join the two tables from the csv files with an inner join.
 
Upvote 0
I would use Power Query and Join the two tables from the csv files with an inner join.
the user will use different input for csv file .

Could using power query and the process will be automatic for every time ?

I will upload my workbook and let me know ,what is the best solution for that .thanks for help
 
Upvote 0
Can be automatic if csv file is updated. This site does not allow uploading of workbooks. You will need to either use XL2BB for samples or load to a third party ie, Box.net or Dropbox.
 
Upvote 0
You could use 2 different folders for your CSV files (lets call them Data and Source). One type of CSV file in each folder.
So for example you could have "Data 2024-08-01.csv", "Data 2024-08-02.csv" en so forth in the Data folder and "Source 2024-08-01.csv", "Source 2024-08-02.csv" en so forth in the Source folder.

Then with power query you can read all the Data csv files into one table, and all the Source csv files into another table. Then do the inner join, etc.

You only work would be to make sure the correct files are in each folder and open the excel file and hit update.

Would that work for you?

Let us know and we could help you do it.

(A sample of your csv files would be helpful)
 
Upvote 0
i could not upload the workbook so i took screenshots.
what is the best solution to get the output as described .

first csv.png


second csv.png



output.png
 
Upvote 0
i have forgot to mention that first csv file conains a table seperated with ; between each column
the second csv file contains a table seperated with comma , between each column .
Thanks in advance
 
Upvote 0
Cannot manipulate data in a picture. Please reload your samples using xl2bb.
 
Upvote 0
i am not sure , how to use l2bb . so i have uploaded them here .

Cannot manipulate data in a picture. Please reload your samples using xl2bb.
 
Upvote 0
Sorry, but I am not familiar with the download site and it is requiring me to sign up. No thanks. Good Luck. I'm out unless you use MrE's XL2BB functionality. Instructions are on the site. Read the forum rules and help.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top