VBA compile Error: Do without Loop [Solved/Closed]

Arisfish 1 Posts Wednesday June 28, 2017Registration date June 28, 2017 Last seen - Jun 28, 2017 at 01:58 PM - Latest reply: ac3mark 10542 Posts Monday June 3, 2013Registration dateModeratorStatus September 24, 2018 Last seen
- 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


See more 

1 reply

ac3mark 10542 Posts Monday June 3, 2013Registration dateModeratorStatus September 24, 2018 Last seen - Jun 28, 2017 at 04:41 PM
0
Thank you
You have alot of If statements, with no End if. With every If, you need an end if! Even if you use else!