In your original post you had:
Sub Test
If ... Then
...
Else If ... Then
...
End If <<<<<<<< Not indented to line up with above If.
If ... Then
...
Else
...
End If
End If
End Sub
The problem is that the indentation is incorrect. It should be --
Sub Test
If ... Then
...
Else If ... Then
...
End If
If ... Then
...
Else
...
End If
End If
End Sub
With the indentation corrected, it is easy to see the double End If's at the end.
In your last post, you have this --
Sub Test
1 If ... Then
2 ...
3 Else If a=True Then b=True
4 If b=True Then
5 ...
6 Else
7 ...
8 b= Not(b)
8 End If
9 End If
10 Whatever is next
End Sub
On line 3, it is bad practice to put anything after the Then.
If you move "b=True" down where it belongs, it looks like this --
Sub Test
1 If ... Then
2 ...
3 Else If a=True Then
4 b=True
5 If b=True Then
6 ...
7 Else
8 ...
9 b= Not(b)
10 End If
11 End If
12 ...
End Sub
Now it is easy to see that the code does not make any sense because you follow the line "b=True" with the line "If b=True..." where b must always be True. The following would fix the problem, but may not be what you intended --
Sub Test
1 If ... Then
2 ...
3 Else If a=True Then
4 b=True
4 END IF
5 If b=True Then
6 ...
7 Else
8 ...
9 b= Not(b)
10 End If
12 ...
End Sub