将信息从Sheet2复制到Sheet1

时间:2019-05-30 07:05:47

标签: excel

我有两张纸(sheet1 / Sheet2)。 Sheet2包含随机数,其中选择了一个随机数,我会将生成的最后一个数字复制到Sheet1列I的最后一行

我尝试了各种代码

Sub passpop()

    Dim v As Variant
    Dim strPassword As String

    With Worksheets("Sheet2")
        v = .Cells(.Rows.Count, "A").End(xlUp).Value
            .Cells(.Rows.Count, "A").End(xlUp).Cut .Cells(.Rows.Count, "B").End(xlUp)(2)
    End With

    With Worksheets("Sheet1")
        Sheet1.Range("I13:I13") = v
    End With

End Sub

1 个答案:

答案 0 :(得分:0)

复制粘贴的两种方法:

Option Explicit

Sub Paste()

    'Copy Paste with value and formatting
    Sheet1.Range("A1").Copy Sheet2.Range("A1")

    'Copy Paste only value
    Sheet1.Range("A2").Copy
    Sheet2.Range("A2").PasteSpecial Paste:=xlPasteValues

End Sub