Hello to all.
this macro does not work on merged cells, an aid to correct?
Private Const FCheckRgAddress As String = "Q2,T2,R12,U13" '<<< celle inibite
Private Sub Worksheet_Change(ByVal Target As Range)
Const Pattern = "[ * < / > : ! ? \ | ]"
Dim C As Long
If Target.Cells.Count = 1 Then 'agisci solo se la cella modificata č unica
If Not Intersect(Target, Range(FCheckRgAddress)) Is Nothing Then
For C = 1 To Len(Pattern) 'per ogni carattere in Pattern
If InStr(Target, Mid(Pattern, C, 1)) <> 0 Then 'se il carattere č presente in Target
MsgBox "Sign. " & Environ("UserName") & "" _
& Chr(13) & "hai inserito un carattere non valido!" _
& Chr(13) & "la cella verrā cancella", vbCritical, "ERRORE"
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
Exit Sub
End If
Next C
End If
End If
End Sub
max_max
Bookmarks