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:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
At a minimum, you have three Do's and only two Loop's - fix that then post back if something else errors.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,603
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top