VBA Run-time error 1004 when trying to copy paste cells in a separate sheet

前端 未结 1 1189
春和景丽
春和景丽 2021-01-16 23:51

I am currently getting the following error in my VBA Excel 2007 code: Run-time error \'1004\': Method \'Range\'of object \'_Worksheet\' failed. Having peeled through quite a

相关标签:
1条回答
  • 2021-01-17 00:28

    Update this section:

    If SaveRedAns = 6 Then
            With AccDnn
                .Range(.Cells(2, 71), .Cells(RangéeFinAcc - 1, 87)).Copy
                .Cells(RangéeFinRed - 18, 71).PasteSpecial (xlPasteValues)
            End With
            With DrpRed
                .Range(.Cells(19, 1), .Cells(RangéeFinRed, 16)).Copy
            End With
            AccDnn.Cells(2, 75).PasteSpecial (xlPasteValues)
        Else: SaveRedAns = 7
            Application.ScreenUpdating = True
            Exit Sub
    End If
    

    Or without using With statements:

    If SaveRedAns = 6 Then
            AccDnn.Range(AccDnn.Cells(2, 71), AccDnn.Cells(RangéeFinAcc - 1, 87)).Copy
            AccDnn.Cells(RangéeFinRed - 18, 71).PasteSpecial (xlPasteValues)
            DrpRed.Range(DrpRed.Cells(19, 1), DrpRed.Cells(RangéeFinRed, 16)).Copy
            AccDnn.Cells(2, 75).PasteSpecial (xlPasteValues)
        Else: SaveRedAns = 7
            Application.ScreenUpdating = True
            Exit Sub
    End If
    
    0 讨论(0)
提交回复
热议问题