excel - 粘贴公式中的值

标签 excel vba

好的,我知道如何正常执行此操作,但是我正在使用一些我不是特别熟悉的编码,并且无法使其正常工作。此代码使用日期搜索所有工作表并将具有该日期的行粘贴到报告选项卡上。不幸的是,它粘贴的是公式而不是值。

For shtNum = 5 To Worksheets.Count

'Search Column a for date(s)

     With Sheets(shtNum).Columns(2)

      Set d = .Find(MyDate)

        If Not d Is Nothing Then

           firstAddress = d.Address

             Do

'Copy each Row where date is found to next empty Row on Summary sheet

                d.EntireRow.Copy Sheets("Reports").Range("A" & nxtRw)

                 nxtRw = nxtRw + 1

                Set d = .FindNext(d)

            Loop While Not d Is Nothing And d.Address <> firstAddress

        End If

     End With

 Next

这段代码工作得很好,但因为我不确定如何
d.EntireRow.Copy Sheets("Reports").Range("A" & nxtRw)

它做了什么,我不知道如何编辑代码并使其工作。

最佳答案

代替:

d.EntireRow.Copy Sheets("Reports").Range("A" & nxtRw)

和:
d.EntireRow.Copy
Sheets("Reports").Range("A" & nxtRw).PasteSpecial Paste:=xlPasteValues

关于excel - 粘贴公式中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41559263/

相关文章:

excel - 使用 ActiveWorkbook.SaveCopyAs 文件名时出现运行时错误

excel - Excel 2016 中的数字格式为 10K 5M 等

VBA 计数函数

excel - 为什么在调整用作 ListBox 的 RowSource 的 Table/ListObject 后,Excel 会卡住?

vba - ADODB 连接线上未设置“91”对象变量/With block

vba - 如何在不调用 _Change 函数的情况下清除用户表单文本框?

vb.net - 如何使用VB.net在Excel中选择单元格A3?

excel - 选择大小写错误输出和不匹配错误

excel - VBA复杂vlookup

vba - 从 PST 文件中移动所有项目