Need help with a macro to lock cells based on the criteria of column header, for example in the attached file , i need all cells locked with column header "Texas" i.e, from column D,H,L,P,T,X from Row 7 to 32.
According to your attachment a VBA starter demonstration :
Code:
Sub Demo1()
Dim Rg As Range, A$
With Sheet1.UsedRange
.Parent.Unprotect
.Locked = False
Set Rg = .Rows(1).Find("Texas")
If Not Rg Is Nothing Then
A = Rg.Address
Do
.Columns(Rg.Column).Locked = True
Set Rg = .Rows(1).FindNext(Rg)
Loop Until Rg.Address = A
Set Rg = Nothing
End If
.Parent.Protect
End With
End Sub
Do you like it ? So thanks to click on bottom right Like !