Sorry to bother again guys,
Normally I like to have my answers by my self but this time I found the same answer everywhere but it does not work on me.
I'am importing a CVS file named (Test) and when it comes to my current Workbook the "sheet name" does not take the "File Name" amd it keeps giving the sheets the normal name.. Sheet1, Sheet 2, Sheet 3 etc etc.
Does any of you can take a look to my Code...
I will appreciate.
HTML
Sub ImportThisOne(sFileName As String)
'MsgBox "sFileName =" & sFileName ' I add this to be sure that the name is the correct.
ActiveWorkbook.Worksheets.Add After:=Sheets(Sheets.Count)
'import data
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & sFileName & "", Destination:=Range("$A$1"))
.Name = "sFileName"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Display More