data validation NOT equal to a word

michaelsmithgall

New Member
Joined
Feb 22, 2011
Messages
19
i want to allow any word to be entered except one. i am also using a diffent cell for the data validation.

example

a1= "any customer name"
a2= data validation that essentially says A1 may contain any word as long its its not equal to "Superman"

i dont really have anything agains Superman, thats just an example. if they were to enter superman in this example they would get one of the standard validation msg boxes.

i tried entering in the A2 validation box a custom validation =A1<>"Superman" but that didnt work. it popped the msg on everything
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
If you want to prevent "Superman" from being entered into A1, then the validation rule goes in A1.
 
Upvote 0
Something like this in Worksheet Change event

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
    If Range("A1").Value = "Superman" Or Range("A1").Value = "superman" Then
        MsgBox ("Cell A1 cannot be superman please enter something else")
        Range("A1").ClearContents
    End If
End If
 
End Sub
 
Upvote 0
Stnkynts - i cant seem to get it to work. it looks logical but im missing something. im using the superman name and nothing happens. this is exactly what i am using which i think only has the cell reference changed.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$c$4" Then
If Range("c4").Value = "Superman" Or Range("c4").Value = "superman" Then
MsgBox ("Cell A1 cannot be superman please enter something else")
Range("c4").ClearContents
End If
End If

End Sub
 
Upvote 0
String comparisons in VBA are case-sensitive by default.

Code:
If Target.Address = "$[COLOR=red][B]C[/B][/COLOR]$4" Then
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top