Results 1 to 4 of 4

Loop without Do compile error

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-03-2009
    Location
    Providence RI
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    260

    Loop without Do compile error

    Hello,

    I can't seem to figure this one out and I don't know why. I have a dozen or so loops just because they are looping until the 3rd party app screen updates. These are no problem and I have used many of them before and it works fine. However, my main loops arent letting me loop for some reason and I can't seem to figure out why. I know some of this code will not make sense because it is a 3rd party app...unfortunately this makes some of my code a bit messier than I would like but either way. The error comes up with the 2nd to last loop. I'm going to skip the start of the code, but all variables are assigned and there is no do or loop commands above this. I have checked all loops inside the original loops and verified they start and end.

    All of the Do Loops between are purely for waiting on the screen to update which is why they basically do nothing besides waste time.

    What am I missing here? Sorry I know this VBA 101 type question

    ' Run Through Parent Claims on worksheet
    Do Until Len(Trim(Range("C" & SheetRow).Value)) = 0
        Fraud = False
        NonFraud = False
        RunThrough = False
        OpID = ""
        ParentClaim = ""
        ChildClaim = ""
        Point = ""
        CurrARD = ""
        CurrPAN = ""
        FraudClaim = ""
        FraudChild = ""
        v = 1
        Range("C" & SheetRow) = Replace(Range("C" & SheetRow), "-", "")
        Range("K" & SheetRow) = Abs(DateDiff("d", Now(), Range("E" & SheetRow)))
        PAN = Trim(Range("C" & SheetRow))
        ARD = Trim(Range("D" & SheetRow))
        'Page Up and wait for screen to update
        ExternalApp.SendKeys ("<pa1>")
        Do Until ExternalApp.GetString(17, 40, 6) = "System"
            Sleep (1)
        Loop
        'Page Down and wait for screen to update
        ExternalApp.SendKeys ("<pa2>")
        Do Until ExternalApp.GetString(23, 58, 2) = "p3"
            Sleep (1)
        Loop
        ExternalApp.PutString "IFND", 23, 9
        ExternalApp.SendKeys ("<Enter>")
        'Wait for IFND Screen show show
        Do Until ExternalApp.GetString(18, 2, 4) = "Find"
            Sleep (1)
        Loop
        'Paste ARD and wait for screen to update
        Do Until ExternalApp.GetString(15, 16, 20) = Left(ARD, 20)
            ExternalApp.PutString Left(ARD, 20), 15, 16
            Sleep (1)
        Loop
        'Press enter and wait for screen to update
        ExternalApp.SendKeys ("<Enter>")
        Do Until ExternalApp.GetString(3, 42, 20) = Left(ARD, 20)
            Sleep (1)
        Loop
        Claims = ExternalApp.Area(7, 2, 20, 13).Value
        IFNDArea2 = ExternalApp.Area(8, 53, 21, 58).Value
    ChildLoop:
        ' This one will check each child case, this Do case should never happen as all IF's should exit do prior to this hapenning
        Do Until Len(Trim(ChildClaim)) = 0 And RunThrough = True
            ChildClaim = Split(WorksheetFunction.Trim(Claims), " ")(v)
            'Check if ChildClaim is blank and all child cases have been check for non fraud match
            If Len(Trim(ChildClaim)) = 0 And RunThrough = True Then
                CurrRC = ""
                Range("H" & SheetRow) = "Unable to Locate."
                Exit Do
            'Else If is if all claims have been checked and no non fraud match has been found, now check for fraud matches
            ElseIf Len(Trim(ChildClaim)) = 0 And RunThrough = False And Fraud = False Then
                RunThrough = True
                v = 1
                GoTo ChildLoop
            End If
            'Enter command and childclaim and wait for screen to update
            Do Until ExternalApp.GetString(23, 9, 4) = "IDIS"
                ExternalApp.PutString "IDIS", 23, 9
                Sleep (1)
            Loop
            Do Until ExternalApp.GetString(23, 17, Len(ChildClaim)) = ChildClaim
                ExternalApp.PutString ChildClaim, 23, 17
                Sleep (1)
            Loop
            ExternalApp.SendKeys ("<Enter>")
            Do Until ExternalApp.GetString(2, 51, 4) = "oper"
                Sleep (1)
            Loop
            'Once inside childclaim, pull the below values
            ChildStatus = Trim(ExternalApp.GetString(3, 9, 6))
            CurrARD = ExternalApp.GetString(5, 36, 23)
            OpID = Trim(ExternalApp.GetString(2, 56, 6))
            CurrPAN = ExternalApp.GetString(8, 33, 16)
            Point = Trim(ExternalApp.GetString(2, 41, 6))
            ' ARD Check for Child Claim to check for match
            If CurrARD = ARD Then
                If Point = "DBCC01" Then NonFraud = True ' If ARD Matches, Check Point for Fraud or NonFraud
                If Point = "FRDC01" Then
                    Fraud = True
                    FraudARD = CurrARD
                    FraudPAN = CurrPAN
                    FraudChild = ChildClaim
                    FraudClaim = ParentClaim
                End If
                If NonFraud = False And RunThrough = False Then
                    v = v + 1
                    GoTo ChildLoop
                If Fraud = True Then ' If fraud is true and has run through will update as fraud claim.
                    If InStr(1, IFNDArea2, "DBCC01", vbTextCompare) = 0 Or RunThrough = True Then
                        Range("H" & SheetRow) = FraudClaim
                        Range("I" & SheetRow) = FraudChild
                        Range("J" & SheetRow) = "zFraud"
                        Exit Do
                    ElseIf RunThrough = True Then
                        Range("H" & SheetRow) = FraudClaim
                        Range("I" & SheetRow) = FraudChild
                        Range("J" & SheetRow) = "zFraud"
                        Exit Do
                    End If
                End If
                If NonFraud = True Then ' If ChildClaim is non fraud then enter data on worksheet
                    Range("H" & SheetRow) = ParentClaim
                    Range("I" & SheetRow) = ChildClaim
                    Range("J" & SheetRow) = OpID
                    If Left(Trim(ClaimStatus), 4) <> "PREP" Then  ' Start PREP Check
                        Range("N" & SheetRow) = "Warning: Claim is not in CB Status, Claim is " & ClaimStatus
                    End If  '  End PREP Check
                    If CurrRC <> ReportRC And Len(CurrRC) <> 0 Then ' Start RC Check
                        If Left(Trim(CurrRC), 2) = "48" Then ' Start if MC RC
                           Range("N" & SheetRow) = "Warning: ExternalApp RC of " & CurrRC & " does not match report RC of " & ReportRC
                        End If ' End Check if MC
                    End If ' End RC Check
                    If Not PAN = CurrPAN Then Range("N" & SheetRow) = "ARD Matches. However " & PAN & " doesn't match " & CurrPAN
                    Exit Do
                End If
            End If
        ' ChildClaim Loop
        Loop
        SheetRow = SheetRow + 1
    'Sheetloop for next claim
    Loop
    MsgBox ("Complete")
    Last edited by Dulanic; 09-09-2010 at 12:22 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1