So I am relatively new to vba but am trying. I want a message to show if a user attempts to change a cell based on its column title. Before anyone comments that I can just protect the cells I am aware of this but it would be useful for future knowledge anyway. Rather than having multiple if statements I want to something similar to the where in() that is in SQL. It would be also useful if you could suggest a way of doing not in or would you just use an else? The code I currently have that works for one value is below
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
But 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
Thanks for any help!