我目前面临的问题是我称之为“更新”(已经写好)的模块中的一个子过程,我想执行以下操作;
选择“Sheet2”表数据(一行,A4:KL4),按照上面已经记录的数据顺序复制到“主”表。
子程序还需要包含另一个功能,即在“主”表中搜索参考号的先前条目,如果参考号不存在,则仅复制“表 2”行数据。
如果参考号已经存在,那么它需要检查上一个条目的日期。如果是同一日期,那么我希望子过程覆盖已经保存的内容。如果日期不同,那么我希望子过程将“Sheet2”表添加到新行。
如果有人可以提供帮助,我将不胜感激。我检查了其他帖子,甚至尝试使用以前答案中的一些代码,但它似乎对我不起作用。
Sub update1()
Sheets("loading").Select
Application.ScreenUpdating = False
Sheets("Current Audit").Select
Range("J76").Select
Selection.Copy
Range("AG4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("J77").Select
Application.CutCopyMode = False
Selection.Copy
Range("AF4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B75").Select
Selection.Copy
Range("Q4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B76").Select
Selection.Copy
Range("R4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B77").Select
Selection.Copy
Range("S4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B78").Select
Selection.Copy
Range("T4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B79").Select
Selection.Copy
Range("U4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B80").Select
Selection.Copy
Range("V4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B81").Select
Selection.Copy
Range("W4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("B82").Select
Selection.Copy
Range("X4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B83").Select
Selection.Copy
Range("Y4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B84").Select
Selection.Copy
Range("Z4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("B85").Select
Selection.Copy
Range("AA4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B86").Select
Selection.Copy
Range("AB4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B87").Select
Selection.Copy
Range("AC4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("B88").Select
Selection.Copy
Range("AD4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B89").Select
Selection.Copy
Range("AE4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("AF5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("AG5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("Q5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("R5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("S5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("T5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("U5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("V5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("W5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("X5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("Y5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("Z5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("AA5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("AB5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("AC5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("AD5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("AE5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("GA5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("GE5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("GI5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("GM5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("GP5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("GR5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("GU5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("GW5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("GZ5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("HB5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("HE5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("HH5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
Range("HK5").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C=""N/A"",""N/A"",R[-1]C*100)"
End Sub