I have already done some research and seen what people have posted in the past and I cannot find a solution to this problem. Here is my code. Its pretty simple and bare.
Sub namees()
For r = 1 To 1099
For n = 1 To 315
Debug.Print r & " " & "|||" & " " & n
If Sheets("Sheet1").Cells(r, 13).Value = Sheets("Sheet2").Cells(n, 2).Value Then
Sheets("Sheet2").Cells(n, 8).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Exit For
End If
If r = 1092 And n = 311 Then
MsgBox "here"
End If
Next n
Next r
End Sub
You can test this code with 2 blank sheets. It never reads the If r = 1092 And n = 311 Then. Why does it do this? I mentioning this line because if it read this line, then it would execute the other if statement above. But it skips just about all of it, but counts correctly in debug.print.
Edit: Also, if I run the entire code using F8 then it works like it's suppose to.
Bookmarks