VBA compile Error: Do without Loop

Solved/Closed
Arisfish Posts 1 Registration date Wednesday June 28, 2017 Status Member Last seen June 28, 2017 - Jun 28, 2017 at 01:58 PM
 Blocked Profile - Jun 28, 2017 at 04:41 PM
Hello,
So I modfied this code from an CCM post.

I have Do
I have an End IF

Why am I getting the Error?
  • This query is copying data from sheet one to four other sheets based on criteria in column C.


please help. Thank you.

Sub Metrics()

With Sheets
.Add().Name = "Bounce"
.Add().Name = "Click"
.Add().Name = "Open"
.Add().Name = "Sent"
End With


Set a = Sheets("Sheet1")
Set b = Sheets("Sent")
Set c = Sheets("Open")
Set d = Sheets("Click")
Set e = Sheets("Bounce")

Dim x
Dim z

x = 1
z = 2

Do Until IsEmpty(a.Range("C" & z))

If a.Range("C" & z) = "Sent" Then
x = x + 1
b.Rows(x).Value = a.Rows(z).Value

Else

If a.Range("C" & z) = "EmailOpen" Then
x = x + 1
c.Rows(x).Value = a.Rows(z).Value

Else

If a.Range("C" & z) = "EmailClick" Then
x = x + 1
d.Rows(x).Value = a.Rows(z).Value

Else

If a.Range("C" & z) = "Failed" Then
x = x + 1
e.Rows(x).Value = a.Rows(z).Value

Else

End If
z = z + 1

Loop

End Sub


1 response

Blocked Profile
Jun 28, 2017 at 04:41 PM
You have alot of If statements, with no End if. With every If, you need an end if! Even if you use else!
0