Maybe this could work
Sub MergeCSVs()
Dim FilePath1 As String
Dim FilePath2 As String
Dim DestSheet As Worksheet
Dim FSO As Object
' FileSystemObject
Dim TextStream1 As Object
' TextStream for first file
Dim TextStream2 As Object
' TextStream for second file
Dim DataArray1 As Variant
Dim DataArray2 As Variant
Dim RowCounter As Long
Dim ColCounter As Long
Dim OutputRow As Long
' Get the file paths from the user
FilePath1 = Application.GetOpenFilename(FileFilter:="CSV Files (*.csv), *.csv", Title:="Select the first CSV file (semicolon delimited)")
If FilePath1 = False Then Exit Sub
' User cancelled FilePath2 = Application.GetOpenFilename(FileFilter:="CSV Files (*.csv), *.csv", Title:="Select the second CSV file (comma delimited)")
If FilePath2 = False Then Exit Sub
' User cancelled
' Set the destination sheet (you can change this if needed)
Set DestSheet = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
DestSheet.Name = "MergedData"
OutputRow = 1
' Create FileSystemObject
Set FSO = CreateObject("Scripting.FileSystemObject")
' Process the first CSV file (semicolon delimited)
On Error Resume Next
' In case the file doesn't exist
Set TextStream1 = FSO.OpenTextFile(FilePath1, 1)
' ForReading
On Error GoTo 0
If Not TextStream1 Is Nothing Then
Do Until TextStream1.AtEndOfStream
DataArray1 = Split(TextStream1.ReadLine, ";")
For ColCounter = LBound(DataArray1) To UBound(DataArray1)
DestSheet.Cells(OutputRow, ColCounter + 1).Value = Trim(DataArray1(ColCounter))
' Trim to remove extra spaces
Next ColCounter
OutputRow = OutputRow + 1
Loop
TextStream1.Close
Else
MsgBox "Could not open the first CSV file.", vbExclamation
End If
' Process the second CSV file (comma delimited)
On Error Resume Next
' In case the file doesn't exist
Set TextStream2 = FSO.OpenTextFile(FilePath2, 1)
' ForReading
On Error GoTo 0
If Not TextStream2 Is Nothing Then
Do Until TextStream2.AtEndOfStream
DataArray2 = Split(TextStream2.ReadLine, ",")
For ColCounter = LBound(DataArray2) To UBound(DataArray2)
DestSheet.Cells(OutputRow, ColCounter + 1).Value = Trim(DataArray2(ColCounter))
' Trim to remove extra spaces
Next ColCounter
OutputRow = OutputRow + 1
Loop
TextStream2.Close
Else
MsgBox "Could not open the second CSV file.", vbExclamation
End If
' Clean up the FileSystemObject
Set TextStream1 = Nothing
Set TextStream2 = Nothing
Set FSO = Nothing
MsgBox "CSV files merged successfully into sheet '" & DestSheet.Name & "'.", vbInformation
End Sub