Sub VishalCsvInput()
Dim dim1 As Integer, dim2 As Integer, fileNum As Integer
Dim delim As String, element As String
Dim strCSV As String
Dim fd As FileDialog
Dim initArray As Variant, finArray As Variant, selectedFile As Variant
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fileNum = 1
delim = InputBox(Prompt:="Delimiter Selection", Title:="Please enter your required delimiter", Default:=",")
With fd
If .Show = -1 Then
For Each selectedFile In .SelectedItems
strCSV = ImportTextFile(selectedFile)
initArray = Split(strCSV, vbCrLf)
dim1 = UBound(initArray)
dim2 = UBound(Split(initArray(0), delim))
ReDim finArray(dim1, dim2)
For Idx1 = LBound(initArray) To UBound(initArray) - 1
For Idx2 = 0 To dim2
element = Split(initArray(Idx1), delim)(Idx2)
finArray(Idx1, Idx2) = Replace(element, "'", "")
Next
Next
Sheets("Sheet1").Range("A" & fileNum).Resize(UBound(finArray), UBound(Application.Transpose(finArray))) = finArray
fileNum = fileNum + 100
Next selectedFile
End If
End With
End Sub
Function ImportTextFile(strFile As Variant) As String
Open strFile For Input As #1
ImportTextFile = Input$(LOF(1), 1)
Close #1
End Function