Link to home
Start Free TrialLog in
Avatar of uTab
uTab

asked on

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
Avatar of hongjun
hongjun
Flag of Singapore image

your syntax is correct
Avatar of kiranghag
kiranghag

i put it in vb here and its perefect without error!
This is your question
>>I am getting a loop without do error
No errors mean good right? Isn't this what you wanted
Avatar of uTab

ASKER

But there is an error it is loop without do.
sorry i don't quite get you.
What do you mean?
Avatar of uTab

ASKER

The post prior to you yours telling me that this is what I wanted is not from me.  I do have an error
what is the error?
post the error message here.
I also pasted the code in but i got no error.
Avatar of uTab

ASKER

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
do you have got Sheet1?

hongjun
Avatar of uTab

ASKER

Yes
Avatar of uTab

ASKER

Could I email someone the entire code because I can not post it?
ASKER CERTIFIED SOLUTION
Avatar of Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of uTab

ASKER

Nope, but it was worth a try
can i also have a copy? noel_b_castillo@yahoo.com
       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
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: https://www.experts-exchange.com/help.jsp#hs8

You have done exactly what they said is not allowed.
You are right.

I had read this when i joined experts-exchancge,but i had forgoten it.My fault
Avatar of uTab

ASKER

I am sorry I did not read the rule properly.
@uTab

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

hongjun