用vba重做一个文本文件

时间:2019-06-06 09:20:39

标签: excel vba sap

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

来做到这一点
      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 个答案:

答案 0 :(得分:2)

您可以在该语句后添加一些内容,以删除所需的范围

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