求助for循环语句,整个编码写的对吗
Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As Integer
Dim y As Integer
x = Target.Row
If Target.Count > 1 Then Exit Sub
If Target.Column = 2 Then
For y = 1 To x - 1
If Range("by") = Range("bx") Then
Application.Speech.Speak "条码重复,请检查条码"
MsgBox ("条码重复,请检查条码")
Range("B" & x).Clear: Range("B" & x).Select
Next y
Else: Target.Offset(, 1).Select
End If
If Range("B" & x) <> "" And Range("C" & x) <> "" And Range("B" & x) <> Range("C" & x) Then
Application.Speech.Speak "字符长度或内容不一致,请检查条码"
MsgBox ("字符长度或内容不一致,请检查条码")
Range("B" & x).Clear: Range("C" & x).Clear: Range("B" & x).Select
If Target.Column = 3 Then Target.Offset(1, -1).Select
End If
End Sub