Hi,
Looking to create a .csv file merging macro that can merge files selected by an Excel user into one combined single-sheet Excel document.
In my use case whatever .csv files selected by the user will all have the same set of columns with one header row in each one.
In the past I've used a customized version of the "Merging a Range from Selected Workbooks" from this knowledge page: (https://msdn.microsoft.com/en-us/lib....aspx#Anchor_3
But it's had a few quirks:
- It doesn't account for a header row in first file selected.
- It applies some formatting to columns (specifically noticeable with columns containing dates/times e.g. "dd/mm/yyyy hh:mm:ss" whereby the resulting combined file has lost the date information for a "Custom" format).
I recently stumbled upon this macro which seems promising on this page (Merge list of csv, txt files) (http://analystcave.com/merge-csv-fil...s-in-a-folder/).
But it doesn't fit my use case completely, so I'm looking for help with updating it:
- It is hard-coded which are the input and output files. I'd like the input files to be selected via Application.GetOpenFilename instead and the output to simply be left Open at the end (leaving it to the user to save it).
- It checks for a header row in the first input file but still leaves blank rows in the output file (where the headers would have been for subsequent merged files). There should be no empty rows in between merged files in the output.
Please Login or Register to view this content.
It sounds like it should be an easy quick fix but I've been staring myself blind for a while now, any help is much appreciated.Please Login or Register to view this content.
Bookmarks