![复制行输入时删除公式的宏行](https://linux22.com/image/1619438/%E5%A4%8D%E5%88%B6%E8%A1%8C%E8%BE%93%E5%85%A5%E6%97%B6%E5%88%A0%E9%99%A4%E5%85%AC%E5%BC%8F%E7%9A%84%E5%AE%8F%E8%A1%8C.png)
有专家能告诉我如何防止“每日报告”中的公式被结转吗?具体来说,E2 中有一个公式,我只想结转数据,而不是公式。谢谢!!
Private Sub CommandButton1_Click()
Response = MsgBox("Are you sure?", vbYesNo)
If Response = vbNo Then Exit Sub
Dim nextrow As Long
nextrow = Worksheets("Weekly Summary").Cells(Rows.Count, "A").End(xlUp).Row + 1
Worksheets("Daily Report").Range("E2:E17").Copy Worksheets("Weekly Summary").Range("A" & nextrow)
Worksheets("Daily Report").Range("E3:E17").ClearContents
End Sub
答案1
这是一个复制/粘贴的简单示例,其中公式被其值替换:
Sub KopyKat()
Dim r1 As Range, r2 As Range
Set r1 = Range("A1:A3")
Set r2 = Range("B1:B3")
r1.Copy
r2.PasteSpecial (xlPasteValues)
End Sub