• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

protecting selected range across multiple sheets

Hey good people,

I am trying to protect non-adjacent ranges across multiple worksheets and here's the snipped of the code I have written :

Code:
For Each ws In ThisWorkbook.Worksheets

    If ws.Name <> "topsheet" Then

        Set Rng = Application.Union(Range("m:n"), Range("ad:at"))
        
        ws.Cells.Locked = False
        
        Rng.Locked = True
               
        ActiveSheet.Protect Password:="biscuits", DrawingObjects:=False, Contents:=True, Scenarios:=False
    
    End If
    
Next

but the code is breaking at the line Rng.Locked with the error : 81809

The workbook is also attached for ready reference here.

Kindly help me with in case I am missing anything in the code...

appreciate the help.
 

Attachments

  • MMR Nov'22 Compiled Pan India.xlsm
    124.7 KB · Views: 6
Back
Top