简体   繁体   English

将数据从一张纸追加到另一个Excel VBA

[英]Appending data from one sheet to another Excel VBA

I know a bit of VBA, however I got a problem, I am trying to write a code that will copy all data from 1 sheet, append/paste it into the next blank cell in sheet 2 and then remove the data from sheet 1. I am using below code, but I get cell values replaced by the word TRUE. 我知道一些VBA,但是我遇到了一个问题,我正在尝试编写一个代码,该代码将复制1张工作表中的所有数据,将其粘贴/粘贴到工作表2中的下一个空白单元格中,然后从工作表1中删除数据。我正在使用下面的代码,但是我将单元格值替换为单词TRUE。

Sub Instal_Sum_Paste()

  ActiveWorkbook.Sheets("Vehicle working").Select

  Dim N As Long
  N = Cells(6, 2).End(xlDown).Row
  Set DT = Range("b6:G" & N)
  DT.Copy

  ActiveWorkbook.Sheets("Installation Summary").Select
  lMaxRows = Cells(Rows.Count, "B").End(xlUp).Row
  Range("B" & lMaxRows + 1).Select
  ActiveCell.Value = DT.PasteSpecial(xlPasteValues)

  ActiveWorkbook.Sheets("Vehicle working").Select
  DT.Select
  Selection.ClearContents

  MsgBox "done", vbOKOnly, "done"

End Sub

I managed to find an answer, its silly I know: 我设法找到一个答案,它很愚蠢,我知道:

 Sub Instal_Sum_Paste()

  ActiveWorkbook.Sheets("Vehicle working").Select

  Dim N As Long
  N = Cells(6, 2).End(xlDown).Row
  Set DT = Range("b6:G" & N)
  DT.Select
  Selection.Copy

  ActiveWorkbook.Sheets("Installation Summary").Select
  lMaxRows = Cells(Rows.Count, "B").End(xlUp).Row
  Range("B" & lMaxRows + 1).Select
  Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone

  ActiveWorkbook.Sheets("Vehicle working").Select
  DT.Select
  Selection.ClearContents

  MsgBox "done", vbOKOnly, "done"

End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Excel VBA代码可将数据从一张纸复制到另一张纸 - Excel VBA code that copies data from one sheet into another Excel使用VBA将数据从一张纸复制到工作表上的另一张 - Excel copy data from one sheet to another on worksheet refresh with vba 使用excel VBA将数据从一张纸复制并粘贴到另一张纸,然后从第二张纸复制到第三张纸 - Copy and paste data from one a sheet to another sheet, and from second sheet to third using excel VBA VBA从一个Excel工作表复制到另一个Excel工作表? - VBA copying from one excel sheet to another excel sheet? 如何从一个工作表中复制列数据,然后将其复制到VBA Excel中的另一工作表 - How to copy column data from one sheet and then copy that to another sheet in vba excel 使用VBA将数据从一张纸移动到另一张纸 - Move data from one sheet to another with VBA VBA将数据从一个工作表复制到另一个工作表 - VBA Copy data from one sheet to another VBA-将数据从一张纸复制到另一张纸 - VBA - Copy data from one sheet to another Excel VBA将数据从一个工作表复制到另一个工作表,而不会在另一工作表上进行用户输入 - Excel VBA copy data from one worksheet to another off of user input on another sheet 在excel VBA代码中停止数据复制,将数据从一个工作表复制到另一个工作表 - Stop data duplication in excel VBA code that copies data from one sheet into another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM