1

I have a text file, I imported it into Excel thanks to VBA now I would like to remove the first column and the first 9 rows. You think it's possible to do that by rewriting the following code

      With ActiveSheet.QueryTables.Add(Connection:= _
     "TEXT;" & fpath & "\" & ffilename, Destination:=Range("$A$1"))
     .Name = "text"
     .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 = True
     .TextFileSemicolonDelimiter = False
     .TextFileCommaDelimiter = False
     .TextFileSpaceDelimiter = False
     .TextFileOtherDelimiter = "|"
     .TextFileColumnDataTypes = Array(1)
     .TextFileTrailingMinusNumbers = True
     .Refresh BackgroundQuery:=False
 End With

Example

1 Answer 1

2

You can add after that statement something to delete the ranges you want

With ActiveSheet
    .Columns(1).EntireColumn.Delete 'delete first column
    .Rows("1:9").EntireRow.Delete 'delete first 9 rows
End With
Sign up to request clarification or add additional context in comments.

1 Comment

You can also limit where the data starts at import: .TextFileStartRow = 10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.