Code:
Sub check1()
Dim pre1 As Range
Dim nex1 As Boolean
Dim result1 As Integer
For Each pre1 In Range("d1")
If pre1.Value = 23 Then
If pre1.Offset(, 1) = 15 Then
nex1 = True
End If
If nex1 = False Then
result1 = -779
ElseIf nex1 = True Then
result1 = 221
End If
pre1.Offset(1, 1) = result1
End If
Next pre1
End Sub
d2 -- pre1.offset(,1) is 15, but result1 always return as -779, which means nex1 is false; but in my code, I said If pre1.Offset(, 1) = 15 Then nex1 = true.
I don't understand what is the wrong with my code, can someone please help