Sub LockSpecificColumnsAndProtectSheet()
Dim ws As Worksheet
Set ws = [Link]("WL")
' Define your password
Dim strPassword As String
Dim wbPassword As String
strPassword = "Oman@2024" ' Password for sheet protection
wbPassword = "OmanWb2024" ' Password for workbook protection
' Unprotect the sheet with the password if it's already protected
[Link] Password:=strPassword
' Unlock all cells on the sheet
[Link] = False
' Lock entire columns A, B, and H
[Link]("A").Locked = True
[Link]("B").Locked = True
[Link]("H").Locked = True
' Make sure that AutoFilters are enabled before protecting the sheet
If [Link] = False Then
[Link]("A1").AutoFilter
End If
' Protect the sheet with a password to enforce the locking
' Enable AllowFiltering to keep the drop-down filter option available
[Link] Password:=strPassword, DrawingObjects:=True, Contents:=True,
Scenarios:=True, AllowFiltering:=True
' Protect workbook to prevent hiding/unhiding sheets, renaming sheets,
moving/copying sheets, and changing tab colors
[Link] Password:=wbPassword, Structure:=True, Windows:=False
End Sub