Results 1 to 5 of 5

Macro not running on protected worksheets

Threaded View

  1. #1
    Registered User
    Join Date
    09-30-2009
    Location
    Malta
    MS-Off Ver
    Excel 2003
    Posts
    18

    Macro not running on protected worksheets

    Hi All,
    I need help. I am using the following codes first to protect all worksheets and then I run the code to unprotect all sheets to make some corrections.
    When I run the Unprotect code after all worksheets have been protected, I am getting Run-time Error 1004 (all as hereunder.
    I know I am missing something. Would anyone know what this something is please?

    Thanks for help
    paraxis

    ' Macro to protect multiple sheets
    Option Explicit
    Sub protectSheets()
        Dim i As Long
        For i = 1 To Sheets.Count
            Sheets(i).protect Password:="123"
        Next i
    End Sub
    
                                                      
    ' Macro to unprotect multiple sheets
    
    Sub UnProtectSheets()
     Dim i As Long
         For i = 1 To Sheets.Count
             Sheets(i).Unprotect Password:="123"
         Next i
     End Sub
    Giving error
    Run-time Error '1004'
    The password you supplied is not correct. Verify that the CAPS LOCK key is off
    and be sure to use the correct capitalisation.
    Last edited by royUK; 11-12-2010 at 05:36 AM. Reason: add code tags

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