I am having trouble making a program work in Excel.
I need loop through all the lines in my excel spreadsheet, and loop through multiple possible cells for each line.
Sub DoubleLoop()
Dim i As Long
Dim Carr As Integer
For i = 2 To 49235
For j = 2 To 27
If Range("P" & i).Value = ("Y" & j) And Range("S" & i).Value = ("Z" & j) And Range("P" & i).Value = ("AA" & j) Then
Range("P" & i).Value = "Keep"
ElseIf j < 27 Then
j = j + 1
ElseIf j = 27 Then
Range("X" & i).Value = "Remove"
End If
Next i
End Sub
Next jfrom your code. Is that what is causing your error?Next jis missing.Nexts,End Ifs, and other closing statements, become very obvious.Next j,j = j + 1will be redundant.