+ Reply to Thread
Results 1 to 5 of 5

paste value into protected sheet error 1004

  1. #1
    Registered User
    Join Date
    05-04-2016
    Location
    belgium
    MS-Off Ver
    2013
    Posts
    2

    Unhappy paste value into protected sheet error 1004

    Hi
    i'am trying to add some values from worksheet2("jan") into a password protected worksheet1("staff"). Password = "123"

    I'am able to insert a blank row into worksheet1 (on the fifth row), but my code allways fails when i try to past the values. error 1004
    I'am using a commandbutton on worksheet "Jan" below my code:

    Option Explicit

    Sub Knop1_Klikken()
    on error goto ErrorRoutine
    Range ("a2:e2").select
    Selection.Copy
    Worksheets("staff").Select
    Worksheets("staff").activate
    Worksheets("staff").Unprotect ("123")
    Range("A5").Select
    Range("A5").EntireRow.Insert Shift:=xlShiftDown
    Range("a5:e5").Locked = False
    ActiveSheet.PasteSpecial Paste:=xlPasteValue 'here occurs the error 1004, paste or pastespecial don't matters
    Application.CutCopyMode = False
    Worksheets("staff").Protect ("123")

    exitroutine:
    Exit Sub
    foutroutine:
    MsgBox Err.Number & " " & Err.Description
    resume next

    End Sub


    What i'am doing wrong ??

    many thanks to figure this out with me, Padob

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: paste value into protected sheet error 1004

    Please Login or Register  to view this content.
    The Paste method needs a Range to paste into... Not just a worksheet. For example
    Please Login or Register  to view this content.
    Also:
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: paste value into protected sheet error 1004

    Just a small note to add that the code posted would not run at all, so it might be helpful to add your real code while you are correcting the code tags.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Registered User
    Join Date
    05-04-2016
    Location
    belgium
    MS-Off Ver
    2013
    Posts
    2

    Re: paste value into protected sheet error 1004

    hi,
    i'am sorry for the violation of the forumrules. it was out of my mind and partially caused by my knowlege of english

    I've changed activeSheet.paste... into ActiveSheet.Range("a5:e5").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False ,
    but the error still occurs.
    regards, PAtrick

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: paste value into protected sheet error 1004

    Most likely the clipboard is being cleared either when you unprotect the sheet, or when you insert the row.

    And you're still not using code tags.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 08-01-2016, 03:47 PM
  2. When Activesheet.paste, Run-Time error '1004': Paste method of work sheet class failed.
    By devaraj2020 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-27-2015, 01:59 AM
  3. Run Time Error 1004 - You cannot use this command on a protected sheet
    By frogboy in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-11-2012, 07:59 AM
  4. Macros stop to work when work sheet is protected. Run time error 1004
    By sellim in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-18-2012, 01:14 AM
  5. VB run time error 1004 on protected sheet
    By Twaddy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-27-2010, 05:07 PM
  6. Cannot copy&paste chart to new sheet (runtime 1004 error)
    By bubastisbastet in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2010, 07:13 AM
  7. Run-time error 1004 when sheet is protected
    By AJ. in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-05-2008, 10:33 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1