Validation of 2 rows of cells, only 'X' or 'x' allowed.
Hi Herrie
I suspect that Application.EnableEvents is set to false, as you probably
crashed after switching it off.
In the Immediate window, type Application.EnableEvents followed by return
You aslo have an End If missing (from your first If statement)
To cover all of the cells in your range, use something like
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRng As Range
Set myRng = Range("D19:J22")' Change to suit
If Not Intersect(Target, myRng) Is Nothing Then
Debug.Print "oke"
Application.EnableEvents = False
If Target.Text < "X" And Target.Value < "x" Then
MsgBox "Alleen aankruisen met een 'X' of een 'x'!"
Target.ClearContents
Target.Select
End If
End If
Application.EnableEvents = True
End Sub
--
Regards
Roger Govier
"Herrie" wrote in message
...
Hello,
After roaming through the Search resluts on "Validation" I still have not
found a solution to my question.
I have a worksheet, that will be sent to a list of volunteers, who can
mark
theu availability on this sheet by putting a "x" or "x" (a cross) in 2
rows
of cells.
(These rows are weekdays, morning/afternoon/evening)
I ONLY want an "X" (or "x") in these 2 x 21 cells.
I tried this snipet
[snippet]
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$19" Then
Debug.Print "oke"
Application.EnableEvents = False
Target.Text = Trim(Target.Value)
If Target.Text < "X" And Target.Value < "x" Then
MsgBox "Alleen aankruisen met een 'X' of een 'x'!"
Target.ClearContents
Target.Select
End If
Application.EnableEvents = True
End Sub
[/snippet]
on the first cell (D19) but nothing happens, no msgbox, nothing....
Where do I go wrong?
Any suggestions?
YT
Harry
|