+ Reply to Thread
Results 1 to 6 of 6

Error when trying to protect sheet after exporting data to seperate workbook

  1. #1
    Registered User
    Join Date
    11-08-2013
    Location
    Huntington, NY
    MS-Off Ver
    Excel 2013
    Posts
    3

    Error when trying to protect sheet after exporting data to seperate workbook

    Hi everyone,
    I am getting a Run-Time error '9' on the last line of the following sub. Everything else seems to work fine. Basically, the sub's function is to unprotect the active sheet, copy the specified data, paste in a new workbook, then protect the sheet that the data was copied from.

    I can't seem to find any threads related to this issue so any help is greatly appreciated.

    Thanks,
    Justin

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    06-18-2012
    Location
    Chennai, India
    MS-Off Ver
    Excel 2003, 2010
    Posts
    212

    Re: Error when trying to protect sheet after exporting data to seperate workbook

    Hi Amend the code as below.

    Please Login or Register  to view this content.
    Best
    Rem0

  3. #3
    Registered User
    Join Date
    11-08-2013
    Location
    Huntington, NY
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Error when trying to protect sheet after exporting data to seperate workbook

    Hi Rem0,
    I revised the code as follows and am still getting the same error. Am I entering the code incorrectly?

    Thanks,
    Justin

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    03-28-2013
    Location
    *
    MS-Off Ver
    Excel 2010
    Posts
    226

    Re: Error when trying to protect sheet after exporting data to seperate workbook

    add this
    Please Login or Register  to view this content.
    hi justin, declaring variables is good practice writing code.
    Please Login or Register  to view this content.
    Last edited by venkatpvc; 12-03-2013 at 03:52 PM.
    Give Feedback and Click(*)

  5. #5
    Registered User
    Join Date
    11-08-2013
    Location
    Huntington, NY
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Error when trying to protect sheet after exporting data to seperate workbook

    Hi Venkatpvc,
    I inserted the second line of code using variables and it worked flawlessly. Thank you for the response.

    I reviewed the code and understand how the variables are created and used, however, am having a hard time grasping the advantage of variables.
    Is there a brief explanation or resource that you could direct me to help me better understand? Thanks again.

  6. #6
    Forum Contributor
    Join Date
    03-28-2013
    Location
    *
    MS-Off Ver
    Excel 2010
    Posts
    226

    Re: Error when trying to protect sheet after exporting data to seperate workbook

    i was at your stage, and I am also still learning many things same as you.
    the best way to read and understand others code as you did today.
    and practice thats what i did and doing everyday.

    and thank you for the feedback.

    IF YOU PROBLEM PLEASE MARK THREAD AS "SOLVED"
    Last edited by venkatpvc; 12-03-2013 at 05:18 PM.

+ 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. Exporting each sheet to a new workbook and saving workbook in new folder with timestamp
    By amphinomos in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-19-2013, 11:19 AM
  2. Merge Data into Existing Sheet on Seperate Workbook
    By lsteinbach in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2013, 12:18 PM
  3. [SOLVED] Master workbook to pull data from second workbook into seperate sheet
    By djm601 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-16-2013, 09:24 AM
  4. Exporting data from on sheet across entire workbook
    By elinyc86 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2012, 11:26 PM
  5. Replies: 0
    Last Post: 08-01-2007, 02:03 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