While ... Wend
I greet all
I have problem.
I would like that my code acted as follows:
If user wrote some Text (but only in the odd columns) and if this Text is
incorrect with conditions, display MsgBox and written text becomes
deleted.... but my loop acted to many times....
where is mistake?
Pozdrawiam,
Andrzej
Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As String
Dim k As Integer
x = Target.Value
k = 1
' blokada wpisu niewłaściwej nazwy cechy do zakładki
While k < 254
If Not Application.Intersect(Columns(k), Target) Is Nothing Then
If x <= "NGD" Or x = "NGN" Then
MsgBox " Incorrect data !!! " & Chr(10) & _
Chr(10) & " Try again "
Target.Value = ""
End If
End If
k = k + 2
Wend
End Sub
|