Luuklag
Luuklag

Reputation: 3914

Range paste special results in error 1004

I have a fairly large code but the only thing that fails is pasting of something I copied the row before.

Dim WB_start As Workbook
    Set WB_start = ThisWorkbook
Dim WB_active As Workbook
Dim WSS As Worksheet
Set WSS = WB_active.Worksheets("Samenvatting")
    WSS.Unprotect ("SECRETSTUFF")

    MsgBox (WB_start.Name & " - " & WB_start.Worksheets(1).Name)

    WB_start.Worksheets(1).Range(WB_start.Worksheets(1).Cells(8, 9), _
           WB_start.Worksheets(1).Cells(13, 12)).Copy

    MsgBox (WB_active.Name & " - " & WSS.Name)

    WSS.Range(WSS.Cells(8, 9)).PasteSpecial xlPasteFormulas

The last row here gives me the infamous 1004 error. "Method Range of Object Worksheet failed" . I know that usually means that something isn't propperly qualified, but I am at a loss what that could be. I've inserted messageboxes, and they show the expected workbook and worksheet names.

Upvotes: 0

Views: 474

Answers (1)

Shai Rado
Shai Rado

Reputation: 33682

Change your line:

WSS.Range(WSS.Cells(8, 9)).PasteSpecial xlPasteFormulas

to:

WSS.Cells(8, 9).PasteSpecial xlPasteFormulas

Upvotes: 2

Related Questions