I use the following VBA code to open CSV files in Excel. Most of the time the information from the CSV file is put into columns. However, this is not always the case. Sometimes the data from the CSV file is not put into columns, but just one column. How can I make sure the data from the csv file is always put in columns?
Sub OpenFileBox()
Application.ScreenUpdating = False
Dim FileName As String, test As Workbook
Dim shActive As Worksheet
FileName = Application.GetOpenFilename("Comma Separated Values,*.csv", , "Browse for workbook")
Set shActive = ActiveSheet
Set test = Workbooks.Open(FileName)
test.Sheets(1).UsedRange.Copy shActive.Range("A1")
test.Close SaveChanges:=False
Exit Sub
End Sub