hi,
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, c As String, res As String, i As Integer
Set rng = Range("A1:A10") 'Adapt this range as your wish
Set isect = Application.Intersect(Target, rng)
txt = Array( _
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", _
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", _
"â", "à", "é", "è") ' you can add characters the way you want
If Not isect Is Nothing Then
For i = 1 To Len(Target)
c = Mid(Target, i, 1)
If IsError(Application.Match(c, txt, 0)) Then res = res & Mid(Target, i, 1) & ", "
Next
If Len(Target) > 2 And Len(Target) < 35 Then
If res = "" Then
Exit Sub
Else
MsgBox "The following characters are forbidden : " & res & Chr(10) & _
"Please start again" & Chr(10) & _
"Don't forget : only alphabets of length 3 to 35"
Application.EnableEvents = False
Target = ""
Application.EnableEvents = True
Exit Sub
End If
Else
MsgBox "Don't forget : only alphabets of length 3 to 35"
End If
End If
End Sub
--
isabelle
Le 2012-01-06 04:49, KRISHNA a écrit :