I want a message to show if a user attempts to change a cell based on its column title. I could just protect the cells but it would be useful for future knowledge anyway.
Rather than multiple if statements I want something similar to the where in() that is in SQL. Is there a way of doing not in or would you just use an else?
Code that works for one value
Dim ThisColumn as long
ThisColumn=Target.Column
If Cells(1, ThisColumn).Value = "# workers" Then
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
MsgBox "Protected Columns"
Exit Sub
End If
I want something like
If Cells(1, ThisColumn).Value in("# workers","# of people") Then
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
MsgBox "Protected Columns"
Exit Sub
End If