+ Reply to Thread
Results 1 to 5 of 5

Run-Time error '1004': when running my code

  1. #1
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Run-Time error '1004': when running my code

    Evening Happy campers,

    I have 7 spreadsheets (identical apart from saved name) that have 2 command buttons in each, 1st to save the data that has been entered, 2nd to clear all data from specific cells to allow a fresh start.
    My issue is with the first code.
    *THIS code works fine, no issue, does what i wanted it to.*
    Please Login or Register  to view this content.
    *THIS code does not work*
    Please Login or Register  to view this content.
    When i run the code that activates sheetsK7 it brings up a runtime error - *Run-time error '1004': Select method of range class failed* when i click debug, it highlights the following line In yellow as the issue.
    Please Login or Register  to view this content.
    This is the case for all other sheets, they are named as K1, K2, K3, K4, K5, K6 & K7, yet only K6 appears to work??

    Could someone please explain what i am doing wrong here?
    Many thanks in advance.
    galvinpaddy
    Last edited by galvinpaddy; 05-11-2012 at 02:25 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Run-Time error '1004': when running my code

    Hello galvinpaddy,

    Is that sheet protected?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Run-Time error '1004': when running my code

    Hi,
    Master Sheet.xls is not protected, however, all the other sheets are. would that cause an issue?

    many thanks

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Run-Time error '1004': when running my code

    Hello galvinpaddy ,

    It can if the cell is locked and the sheet protection does not allow the user to select locked cells. I would have the the macro first remove the worksheet's protection, execute, and the reapply the protection. This will require the password to be in the macro. To prevent others from seeing it, you can always password protect your VBA project.

  5. #5
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    884

    Re: Run-Time error '1004': when running my code

    hhhmmm, the password protection is only active on the sheets K1 - K7 but the cells that are copied in the macro have protection removed to allow copying while locked, the master sheet has no protection on.
    Initially i thought that having 7 sheets with similar names would cause it, so changed all names to 1st line, 2nd line etc. but to no avail

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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