0

I wrote the following code to just copy and paste the same information, but instead of formulas, it will paste as values only.

The code is working, but when it jumps to another sheet, then I have the error 1004 "Anwendungs- oder objektdefinierter Fehler". Could someone help me?

Private Sub CommandButton1_Click()

    Dim wsh As Worksheet
    For Each wsh In ThisWorkbook.Worksheets
    
        For i = 6 To 10:
            If Not IsEmpty(Cells(i, "C")) Then
                wsh.Range(Cells(i, 1), Cells(i, 42)).Copy
                wsh.Range(Cells(i, 1), Cells(i, 42)).PasteSpecial Paste:=xlPasteValues
            End If
        Next   
    Next
    Application.CutCopyMode = False
End sub

0 Answers0