loop without do error

I am getting a loop without do error. Does anyone have a clue?  

 If Attempts <> 100 Then
        Do
            If Sheet3.Range("X") = x Then _
                y2 = Sheet3.Range("y2")
            Sheet3.Range("y2") = Sheet3.Range("try2")
            Attempts = Attempts + 1
            If Attempts = 100 Then
                MsgBox "*** Trapped Out ***" & Chr(10) & _
                    "v = " & v
                Exit Do
            End If
        Loop Until Sheet1.Range("X") < x
    End If
uTabAsked:
Who is Participating?
 
Ioannis ParaskevopoulosConnect With a Mentor Commented:
yes please.

jyparask@yahoo.gr
0
 
hongjunCommented:
your syntax is correct
0
 
kiranghagCommented:
i put it in vb here and its perefect without error!
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
hongjunCommented:
This is your question
>>I am getting a loop without do error
No errors mean good right? Isn't this what you wanted
0
 
uTabAuthor Commented:
But there is an error it is loop without do.
0
 
hongjunCommented:
sorry i don't quite get you.
What do you mean?
0
 
uTabAuthor Commented:
The post prior to you yours telling me that this is what I wanted is not from me.  I do have an error
0
 
hongjunCommented:
what is the error?
0
 
hongjunCommented:
post the error message here.
0
 
Noel_CastilloCommented:
I also pasted the code in but i got no error.
0
 
uTabAuthor Commented:
The error is

Compile error:
Loop without Do

The code is
 If Attempts <> 100 Then
        Do
            If Sheet3.Range("X") = x Then _
                y2 = Sheet3.Range("y2")
            Sheet3.Range("y2") = Sheet3.Range("try2")
            Attempts = Attempts + 1
            If Attempts = 100 Then
                MsgBox "*** Trapped Out ***" & Chr(10) & _
                    "v = " & v
                Exit Do
            End If
        Loop Until Sheet1.Range("X") < x
    End If

the section .range is highlighted
0
 
hongjunCommented:
do you have got Sheet1?

hongjun
0
 
uTabAuthor Commented:
Yes
0
 
uTabAuthor Commented:
Could I email someone the entire code because I can not post it?
0
 
dbrckoviCommented:
Try writing it without underscores "_"
Like this:

    If Attempts <> 100 Then
        Do
            If Sheet3.Range("X") = x Then Y2 = Sheet3.Range("y2")
            Sheet3.Range("y2") = Sheet3.Range("try2")
            Attempts = Attempts + 1
            If Attempts = 100 Then
                MsgBox "*** Trapped Out ***" & Chr(10) & "v = " & v
                Exit Do
            End If
        Loop Until Sheet1.Range("X") < x
    End If
0
 
uTabAuthor Commented:
Nope, but it was worth a try
0
 
Noel_CastilloCommented:
can i also have a copy? noel_b_castillo@yahoo.com
0
 
Ioannis ParaskevopoulosCommented:
       If Attempts2 <> 100 Then
            Do
                If Sheet3.Range("cendPrincipal") = cPrincipal Then _       'Here you forgot to put the underscore
                    choldPay = Sheet3.Range("cpayment")
                    Sheet3.Range("cpayment") = Sheet3.Range("cNextPayTry")
                    Resolve_Payment
                    Attempts2 = Attempts2 + 1
                    If Attempts2 = 100 Then
                        MsgBox "*** Trapped Out ***" & Chr(10) & "HoldPay = " _
                                & choldPay
                        Exit Do
                    End If
                Loop Until Sheet3.Range("cendPrincipal") < cPrincipal
            End If
        End If




try and see if it works now
0
 
dbrckoviCommented:
Hmm....

Are you aware that you just broke one of the most strict rules here at EE.
You have used e-mail to resolve a problem.

See here: http://www.experts-exchange.com/help.jsp#hs8

You have done exactly what they said is not allowed.
0
 
Ioannis ParaskevopoulosCommented:
You are right.

I had read this when i joined experts-exchancge,but i had forgoten it.My fault
0
 
uTabAuthor Commented:
I am sorry I did not read the rule properly.
0
 
hongjunCommented:
@uTab

Perhaps you can post the solution here so that future readers can learn something from it.

hongjun
0
All Courses

From novice to tech pro — start learning today.