仅限粘贴值在Excel VBA代码中使用" find"功能

时间:2014-07-30 08:53:56

标签: excel excel-vba vba

如何进一步修改代码,以便只将值粘贴到我的“Cable_List”工作表而不是“数据”表中的公式。

Dim strLastRow As String
Dim rngC As Range
Dim strToFind As String, FirstAddress As String
Dim wSht As Worksheet
Dim rngtest As String
Application.ScreenUpdating = False
Set wSht = Worksheets("Data")
With wSht.Range("BM:BM")
    Set rngC = .Find(What:="PVC", LookAt:=xlPart)
    If Not rngC Is Nothing Then
        FirstAddress = rngC.Address
        Do
            strLastRow = Sheets("Cable List").Range("A" & Rows.Count).End(xlUp).Row + 1
            rngC.EntireRow.Copy Sheets("Cable List").Cells(strLastRow, 1) 'part where copy and paste was done
            Set rngC = .FindNext(rngC)
        Loop While Not rngC Is Nothing And rngC.Address <> FirstAddress
    End If
End With

致谢:sarasotavince

1 个答案:

答案 0 :(得分:0)

更改此行:

rngC.EntireRow.Copy Sheets("Cable List").Cells(strLastRow, 1)

到此:

rngC.EntireRow.Copy
Sheets("Cable List").Cells(strLastRow, 1).PasteSpecial xlPasteValues
Application.CutCopyMode = False