我创建了一个包含 5 列的电子表格,当用户按下回车键时,它应该将信息复制到第二个电子表格。然而,第二个按钮正在从同一第一列复制信息,但我已经检查过了,两个按钮都选择了 Trade1 和 Trade2 宏。
屏幕截图 1:http ://screencast.com/t/zudhZCIQGA3l 屏幕截图 2:http ://screencast.com/t/6NyW3gTy8oY
正如您在 SS2 中看到的,在按下按钮 2 后,它复制了错误的数据。
代码如下
Sub Trade1()
Sheets("Trades").Select
Rows("2:2").Select
Selection.Insert Shift:=xlDown
Range("A2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R2C2"
Range("B2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R3C2"
Range("C2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R4C2"
Range("D2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R5C2"
Range("E2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R6C2"
Range("F2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R8C2"
Range("G2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R7C2"
Range("H2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R9C2"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R10C2"
Range("J2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R11C2"
Range("K2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R11C2"
Range("K2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R12C2"
Range("P2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R13C2"
Range("Q2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R14C2"
Range("R2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R15C2"
Range("S2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R16C2"
Range("T2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R17C2"
Range("U2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R18C2"
Range("V2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R19C2"
Range("V3").Select
Sheets("Enter Trade").Select
End Sub
Sub Trade2()
Sheets("Trades").Select
Rows("2:2").Select
Selection.Insert Shift:=xlDown
Range("A2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R2C3"
Range("B2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R3C3"
Range("C2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R4C3"
Range("D2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R5C3"
Range("E2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R6C3"
Range("F2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R8C3"
Range("G2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R7C3"
Range("H2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R9C3"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R10C3"
Range("J2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R11C3"
Range("K2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R11C3"
Range("K2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R12C3"
Range("P2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R13C3"
Range("Q2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R14C3"
Range("R2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R15C3"
Range("S2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R16C3"
Range("T2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R17C3"
Range("U2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R18C3"
Range("V2").Select
ActiveCell.FormulaR1C1 = "=+'Enter Trade'!R19C3"
Range("V3").Select
Sheets("Enter Trade").Select
End Sub