如何在不移动数据的情况下将数据粘贴到表中?

时间:2019-06-06 07:14:17

标签: excel vba sap

我制作了一个程序,该程序应该从保存在文本文件中的Excel中复制并粘贴到Excel文件中的数据,除了当我启动该程序时,我移动了表格并将数据粘贴在它旁边。

我正在向您提供我认为有问题的代码。

    Sub OpenCSVFile()
     ' Load the CSV extract
    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 = 4
    .TextFileParseType = xlDelimited
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = False
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileOtherDelimiter = "|"
    .TextFileColumnDataTypes = Array(9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
      1, 1, 1, 1)
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
    End With
    End Sub

我想将数据粘贴到表中而不移动表,因此也不要将其粘贴在表旁边。

之前:

Before

之后:

After

0 个答案:

没有答案
相关问题