HI All,
I am using below code to convert csv to excel, macro is running fine if we select the csv file.
however I need a help .. with the code which can exit the vba once we press cancel or escape button
Thanks
Chandresh
I am using below code to convert csv to excel, macro is running fine if we select the csv file.
however I need a help .. with the code which can exit the vba once we press cancel or escape button
Code:
Sub CSV()
Dim WS As Worksheet, strFile As String
Set WS = ActiveWorkbook.Sheets("Download") 'set tocurrent worksheet name
strFile = Application.GetOpenFilename("Text Files(*.csv),*.csv", , "Please select text file...")
With WS.QueryTables.Add(Connection:="TEXT;" &strFile, Destination:=WS.Range("A1"))
.TextFileParseType = xlDelimited
.TextFileCommaDelimiter = True
.Refresh
End With
End Sub
Chandresh
Last edited by a moderator: