How to Protect Sheet from editing in Multiple Workbooks at once?

VinodKrishnappa

New Member
Joined
Aug 6, 2016
Messages
31
Hi,

I would like to protect a particular sheet from editing in various work book files available in particular folder.

In the sheet i need to enable editing option only particular cells which. Rest all i want to protect

For Ex:
File Name: workbook1.xlsx
Sheet Name: sheet1

In a folder i have multiple workbooks like "workbook1.xlsx", "workbook2.xlsx" and so on... In each work book i want to protect sheet1 from editing/formatting/ except few cells which are unlocked.

Please help me on this. Thanks in advance.

Regards,
VK
 

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
8,610
Try the following macro:
Code:
 Sub ProtectSheet()
    Application.ScreenUpdating = False
    Dim wkbSource As Workbook
    Const strPath As String = "C:\Test\" 'change folder path to suit your needs
    ChDir strPath
    strExtension = Dir("*.xlsx")
    Do While strExtension <> ""
        Set wkbSource = Workbooks.Open(strPath & strExtension)
        With wkbSource
            .Sheets("Sheet1").Protect Password:="mypassword" 'change "mypassword" to suit your needs
            .Close savechanges:=True
        End With
        strExtension = Dir
    Loop
    Application.ScreenUpdating = True
End Sub
Change the folder path to match yours and change the password to one of your choosing.
 

Forum statistics

Threads
1,085,495
Messages
5,384,007
Members
401,871
Latest member
allemandi

Some videos you may like

This Week's Hot Topics

Top