Else without If - And it isn't cause it's a one liner :/

liamtnelson

New Member
Joined
Oct 8, 2014
Messages
2
I have this code in excel, its basically scanning and sorting data from another spreadsheet. Here's where the error pops up..

Do Until wsa.Cells(i, "B") = ""
If wsa.Cells(i, "H") <> 54 Then
i = i + 1
ElseIf wsa.Cells(i, "H") = 54 Then
j = 2
Do
If wsc.Cells(j, "D") = "" Then
wsc.Cells(j, "D") = wsa.Cells(i, "H")
wsc.Cells(j, "E") = wsa.Cells(i, "J")
i = i + 1
ElseIf wsc.Cells(j, "D") = 54 Then
j = 2
Do
If wsa.Cells(i, "J") = wsc.Cells(j, "E") Then
wsc.Cells(j, "F").Value = wsc.Cells(j, "F").Value + 1
i = i + 1
Exit Do
ElseIf wsc.Cells(j, "E") = "" Then
wsc.Cells(j, "D") = wsa.Cells(i, "H")
wsc.Cells(j, "E") = wsa.Cells(i, "J")
i = i + 1
Exit Do
ElseIf wsa.Cells(i, "J") <> wsc.Cells(j, "E") Then
j = j + 1
End If
Loop
End If
Exit Do
End If
Loop
End Sub
 
Last edited:

Some videos you may like

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,184
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
At a minimum, you have three Do's and only two Loop's - fix that then post back if something else errors.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,492
Messages
5,523,260
Members
409,506
Latest member
reneekeane

This Week's Hot Topics

Top