on run Macro gets "Error 1004 paste method of Worksheet class failed" RRS feed

  • Question

  • Greetings, I have a script like:
    "Sub Macro4()
    ' Macro4 Macro


    That I want to take the 12 columns I have on the clipboard (a header row, and first row of data) and simply paste into Q. when I run this I get Error 1004 paste method of Worksheet class failed
    Sorry to say the vba I knew 14 years ago is completely lost to me, anybody tell me what that means? Debugger opens to that line "ActiveSheet.Paste" this is in a spreadsheet with a couple tabs that has been saved as .xlsb If this is to much of a noob question please point me to a better forum.

    Thursday, June 18, 2020 6:05 PM

All replies

  • To:  BoydKn
    re:  pasting copied range values

    Sub test()
     Range("Q1").PasteSpecial xlPasteAll
     Application.CutCopyMode = False
    End Sub

    Free Excel programs/workbooks at MediaFire (no ads)...
    Thursday, June 18, 2020 9:22 PM
  • Does it work if you copy the cells to Clipboard manually, then select Q1 and paste?

    Friday, June 19, 2020 6:36 AM
  • yep, Copy from sheet1 select Q1 in sheet two, paste works fine.
    Monday, June 22, 2020 4:16 PM
  • We do not know, because in code you do not use line with copy command.

    You can check if something is in Clipboard first

    With Application
            .CutCopyMode = False
            .CommandBars("Clipboard").Visible = True
        End With

    You can use to add date to Clipboard this code.

    Dim MyData As MSForms.DataObject
       Set MyData = New MSForms.DataObject
    MyData.SetText = "...."

    Oskar Shon, Office System MVP - www.VBATools.pl
    if Helpful; Answer when a problem solved

    Wednesday, July 1, 2020 7:43 PM