使用vba将多个列复制并粘贴到另一个工作表中

我正在处理一个代码,它将复制几列不合适的数据。 我无法弄清楚如何一步到位,所以我想把它弄成两个。 在第一组列的post后,我很难让它回到我正在复制下一组列。 这就是我的代码到目前为止。

Survey_Macro1macros

range("A:D").Select range(Selection, Selection.End(xlDown)).Select Selection.Copy Sheets.Add.Name = "Data" ActiveSheet.Paste ThisWorkbook.Save ThisWorkbook.Sheets("Table").Activate Application.CutCopyMode = False range("AK:AL").Select range(Selection, Selection.End(xlDown)).Select Selection.Copy ThisWorkbook.Worksheets("Data").range(E1).Select ActiveSheet.Paste 

请参阅如何避免在Excel VBAmacros中使用select 。

 Sub yg23iwyg() Dim wst As Worksheet Set wst = Worksheets.Add wst.Name = "Data" With Worksheets("Table") .Range(.Cells(1, "A"), .Cells(.Rows.Count, "D").End(xlUp)).Copy _ Destination:=wst.Cells(1, "A") .Range(.Cells(1, "AK"), .Cells(.Rows.Count, "AL").End(xlUp)).Copy _ Destination:=wst.Cells(1, "E") 'alternate with Union'ed range - becomes a Copy, Paste Special, Values and Formats because of the union .Range("A:D, AK:AL").Copy _ Destination:=wst.Cells(1, "A") End With End Sub