我从之前发布的一个问题中得到了我需要的帮助:Excel VBA Copying and Pasting into Next Blank Row in Another Sheet . 我在录制的宏上遇到了另一个问题 . 我想提一下我在excel或编码方面没有VBA经验 .

Asinthe在我上一篇文章中提供的代码非常合适 . 但是,如果在工作表1中添加了新行,则我的宏不起作用 . 我相信这是因为指定了范围 . 例如,原始范围B85:K146必须具有相同数量的行和列才能使宏正常执行 . 如果我在B85:K146范围内添加了4个新行,当我运行宏时,新的数据行或该范围之外的任何数据都不会被复制并粘贴到B9区域,我会在其中进行特殊粘贴 . 当我使用击键时,我认为按键会记录该区域,但它实际上记录了确切的范围 . 我需要宏能够从Sheet 1复制一个区域中的任何添加或删除的行,并将所有数据粘贴到Sheet 1中以B9开头的另一个区域中 . 我可以使用任何建议的资源/链接来解决此问题?或者你们都知道可以帮助我的任何代码?

提前致谢!!

Range("A1").Select
Selection.End(xlDown).Select
Selection.End(xlToRight).Select
Range("C3").Select
ActiveCell.FormulaR1C1 = "=DATE(YEAR(RC[-1]), MONTH(RC[-1])+1, DAY(RC[-1]))"
Range("C3").Select
Selection.Copy
Range("B3").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
Range("C3").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("A1").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Range("B85:K146").Select
Selection.Copy
Range("A1").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
Range("B9").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
Range("A1").Select
ActiveSheet.Next.Select
Range("A1").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlToRight).Select
Range("E71:G71").Select
Application.CutCopyMode = False
Selection.Copy
Range("A1").Select
ActiveSheet.Next.Select
Range("A1").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlToRight).Select
Selection.End(xlToLeft).Select
Selection.End(xlUp).Select
Selection.End(xlUp).Select
Selection.End(xlDown).Select
Selection.End(xlToRight).Select
Selection.End(xlToRight).Select
Selection.End(xlToLeft).Select
Range("C5").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Cells(Range("C1000000").End(xlUp).Row + 1, 3).PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False

结束子