Excel VBA复制/粘贴范围到另一个工作表中的下一个可用单元格

我想要做什么:过滤数组,然后将过滤的数据复制到不同的工作簿。 然后将刚刚粘贴到同一工作簿中另一个工作表上的数据复制,但是这次是在现有数据之下。

我的想法:下面我使用的代码是用来帮助我从一个工作簿复制和粘贴到另一个工作簿,并完美地工作,

wb.Sheets("2014 Current Week").Range("C2:CC10000").Copy nwb.Sheets("2014 YTD").Range("C" & Rows.Count).End(xlUp).Offset(1, 0) 

但是如果我想在同一个工作簿中复制它似乎不能以相同的方式工作。 任何帮助,将不胜感激。 谢谢!

 Dim wb as workbook Dim strs As String Dim str As String Dim nwb as workbook Set wb = ThisWorkbook strs = wb.Sheets("Macros").Range("H5") 'the 2014 address can be found in full in cell H5 in the Macros tab set nwb = Workbooks.Open(strs) 'address of new workbook and opens it With ActiveSheet .AutofilterMode = False 'Filter this and that here' End With nwb.Sheets("ALL DATA").Range("A1:CA100000").Copy wb.Sheets("2014 Current Week").Range("C" & Rows.Count).End(xlUp) 'this one works, and copies exactly as I want into the 2014 Current Week tab wb.Sheets("2014 Current Week").Range("C2:CC10000").Copy wb.Sheets("2014 YTD").Range("C" & Rows.Count).End(xlUp).Offset(1, 0) 'this one doesn't work, and does not copy or paste at all from that 2014 Current Week into the 2014 YTD tab of the same workbook 

你的代码看起来不错,不应该有任何问题。 由于它似乎不工作,你需要看看实际的Worksheets和涉及的数据。

您正在使用End来查找最后一行数据。 鉴于此,值得自己来testing一下。 转到C列中Worksheet的最后一行,然后按CTRL + UP 。 这会告诉你数据将被粘贴的位置。

根据你的描述,这最后一行是问题。 因为有一些stream浪的数据影响了End

我只是testing你的代码,它工作正常。 它正确地粘贴数据。 检查你的床单的名字。