
Originally Posted by
Richard Buttrey
Hi,
In much the same way as before but with an extra variable
Dim stFName As String, stfPath As String
stfPath = Application.GetOpenFilename
stFName = Left(StrReverse(Split(StrReverse(stfPath), "\")(0)), InStr(StrReverse(stfPath), "."))
Sheets("Data").Select
With ActiveSheet.QueryTables.Add(Connection:= _
stfPath, _
Destination:=Range("$A$1"))
.Name = stFName
'etc...
Yes, I believe it should be this simple but my knowledge is very limited.
I still get an error though. "Application defined or object-defined error"
Dim stFName As String, stfPath As String
Sheets("Data").Select
'Hämta filnamnet utan extension
stfPath = Application.GetOpenFilename
'Get the name of the file without the file extension. (Make:data_267798_7267.csv become, data_267798_7267)
stFName = Left(StrReverse(Split(StrReverse(stfPath), "\")(0)), InStr(StrReverse(stfPath), "."))
With ActiveSheet.QueryTables.Add(Connection:= _
stfPath, _
Destination:=Range("$A$1"))
.Name = stFName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
Any thoughts?
Bookmarks