Report

VBA compile Error: Do without Loop [Solved]

Ask a question Arisfish 1Posts Wednesday June 28, 2017Registration date June 28, 2017 Last seen - Last answered on Jun 28, 2017 at 04:41 PM by ac3mark
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


Helpful
+0
plus moins
You have alot of If statements, with no End if. With every If, you need an end if! Even if you use else!
Leave a comment

Member requests are more likely to be responded to.

Members can monitor the statuses of their requests from their account pages.

A CCM membership gives you access to additional options.

Not a member yet?

Sign up now. It takes less than a minute and is completely free!