OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 441
- Office Version
- 2019
- Platform
- Windows
Thanks in advance for your assistance.
I am building an if then elseif else loop. I think the issue is the Else if because I want it to meet three criteria:
(1) Column A = 2000
(2) Column M = Blank
(3) Column H's value is in between or equal to these two account numbers 454001 and 540021 and is inclusive of both numbers. These are stored as text.
Please note all three of these conditions must be met on the second condition.
ElseIf (UCase(Cells(i, 1) = "2000") And UCase(Cells(i, 13) = "")) And (UCase(Cells(i, 8) >= "454001" And UCase(Cells(i, 18) =< "540021")) Then
I get "Compile error: Syntax error"
I am building an if then elseif else loop. I think the issue is the Else if because I want it to meet three criteria:
(1) Column A = 2000
(2) Column M = Blank
(3) Column H's value is in between or equal to these two account numbers 454001 and 540021 and is inclusive of both numbers. These are stored as text.
Please note all three of these conditions must be met on the second condition.
ElseIf (UCase(Cells(i, 1) = "2000") And UCase(Cells(i, 13) = "")) And (UCase(Cells(i, 8) >= "454001" And UCase(Cells(i, 18) =< "540021")) Then
I get "Compile error: Syntax error"
Code:
Sub Test()
'Declares the column variables
Dim i As Integer
Dim LastRow1 As Long
LastRow1 = ThisWorkbook.Worksheets("Raw.Data").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Raw.Data").Activate
For i = 2 To LastRow1
If UCase(Cells(i, 1) = "2000") And UCase(Cells(i, 13) = "") And UCase(Cells(i, 12) = "101000") Then
Cells(i, 29) = "Winner"
ElseIf (UCase(Cells(i, 1) = "2000") And UCase(Cells(i, 13) = "")) And (UCase(Cells(i, 18) >= "454001" And UCase(Cells(i, 18) =< "540021")) Then
Cells(i, 29) = "Winner"
Else
End If
Next I
End Sub()