用 vba 重写了一个文本文件

Reworked a text file with vba

我有一个文本文件,感谢 vba,我将其导入 excel 现在我想删除第一列和前 9 行。您认为可以通过重写以下代码来做到这一点

      With ActiveSheet.QueryTables.Add(Connection:= _
     "TEXT;" & fpath & "\" & ffilename, Destination:=Range("$A"))
     .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

您可以在该语句之后添加一些内容来删除您想要的范围

With ActiveSheet
    .Columns(1).EntireColumn.Delete 'delete first column
    .Rows("1:9").EntireRow.Delete 'delete first 9 rows
End With