I created a macro, using the recorder, to add a specific .txt file in my Excel file, using a specific shortcut key, in a specific area of the open excel file. However, I've got this problem: when I use the Macro again, the new data does not override the previous data imported, in the same area, but shifts as much as needed to leave the previous data untouched.
Is there any way to change this, either with an option or through altering the macro code? Specifically, I would like the macro to check if the cells to be written already have data in them, and clear their contents before importing the file data.
Code so far (result of a recoded macro:)
Sub testimport()
'
' testimport Macro
'
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\egw\Desktop\ÍÝïò öÜêåëïò\Book2.txt", Destination:=Range( _
"M14"))
.Name = "Book2"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 737
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
To Dave
- If you want to alert some one, put a @ first. EG,@DaveRook
would have alerted me!