mardi 28 août 2018

Endless loop in reflections

Need help with this macro. Created it and it runs as I want it to, but when it gets to the final page on reflections it does not stop when the RIP Number is " ". Not sure what the issue is. Maybe the placement of that line to tell the macro when to stop? Let me know your thoughts. Thanks in advance.

    Sub RMBR2()
    Dim text As String * 4, continue As String * 4, pl As String
    Dim PGST As Single, PGEND As Single
    Dim USED As String * 3, password As String
    Dim VENDOR As String * 7, FN As String * 4
    Dim QTY As String * 8, PKGLST As String * 10, SHIPDT As String * 6, SID As String * 10, LINE As String * 3
    Dim part As String * 19, ST As String, Part3 As String * 19
    Dim stdate As String * 10, enddate As String * 10
    Dim SZ As Integer, col As Integer, length As Integer, n As Integer, i As Integer, PASTDUE As Integer, OPENSCH As Integer, fai As Integer
    Dim past As Single, CHASSIS2 As String, CHASSIS As String, partNumber As String, partNumber2 As String, counter As String, check As String
    Dim screenString As String
    Dim whichCell As String, cellLabel As String
    Dim excel As Object
    Dim a As String, b As String, c As String, D As String, E As String, F As String, G As String
    Dim ACELL As String, BCELL As String, CCELL As String, DCELL As String, ECELL As String, FCELL As String, GCELL As String
    Dim PART1 As String, PART2 As String

Part3 = InputBox$("PART?", "PART")
VENDOR = InputBox$("SUPPLIER CODE?", "SUPPLIER")

With Application
    .TransmitTerminalKey rcIBMClearKey
    .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
    .WaitForEvent rcEnterPos, "30", "0", 1, 1
    .TransmitANSI "RMBR"
    .TransmitTerminalKey rcIBMEnterKey
    .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
    continue = .GetDisplayText(1, 2, 4)
        If continue <> "RMBR" Then
            password = ""  ' Password has not been recorded for security
            password = .PasswordBox("                                                           Password . . .", "Password")
            .TransmitANSI password
            .TransmitTerminalKey rcIBMEnterKey
            .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        End If
    .MoveCursor 4, 11
    .TransmitANSI Part3
    .MoveCursor 6, 12
    .TransmitANSI VENDOR
    .TransmitTerminalKey rcIBMEnterKey
    .WaitForEvent rcKbdEnabled, "220", "0", 1, 1

     Set excel = CreateObject("Excel.Application")
     excel.Workbooks.Add
      excel.Visible = True

  excel.Columns("A:A").ColumnWidth = 30
  excel.Columns("B:B").ColumnWidth = 30
  excel.Columns("C:C").ColumnWidth = 30
  excel.Columns("A:A").ColumnWidth = 30
  excel.Columns("B:B").ColumnWidth = 30
  excel.Columns("C:C").ColumnWidth = 30
  excel.Columns("G:G").ColumnWidth = 30

   excel.Range("A1").select
   excel.activecell.formulaR1C1 = "RIP NUMBER"

   excel.Range("B1").select
   excel.activecell.formulaR1C1 = "QTY"

   excel.Range("C1").select
   excel.activecell.formulaR1C1 = "PO/ORDER"

    excel.Range("D1").select
    excel.activecell.formulaR1C1 = "LINE"

    excel.Range("E1").select
    excel.activecell.formulaR1C1 = "SCH"

    excel.Range("F1").select
    excel.activecell.formulaR1C1 = "PACKING LIST"

     excel.Range("G1").select
     excel.activecell.formulaR1C1 = "RIP DATE"



RipNumber = .GetDisplayText(9, 6, 10)
QTY = .GetDisplayText(9, 33, 6)
PO = .GetDisplayText(9, 42, 10)
LINE = .GetDisplayText(9, 53, 3)
sch = .GetDisplayText(9, 57, 3)
PLIST = .GetDisplayText(9, 61, 10)
R_DATE = .GetDisplayText(9, 73, 8)



i = 2

Do Until RipNumber = "      "

For n = 9 To 22

c = Trim$(Str$(i))

ACELL = "A" + c
BCELL = "B" + c
CCELL = "C" + c
DCELL = "D" + c
ECELL = "E" + c
FCELL = "F" + c
GCELL = "G" + c



        RipNumber = .GetDisplayText(n, 6, 10)
        QTY = .GetDisplayText(n, 33, 6)
        PO = .GetDisplayText(n, 42, 10)
        LINE = .GetDisplayText(n, 53, 3)
        sch = .GetDisplayText(n, 57, 3)
        PLIST = .GetDisplayText(n, 61, 10)
        R_DATE = .GetDisplayText(n, 73, 8)



                       excel.Range(ACELL).select
                       excel.activecell.formulaR1C1 = "'" + RipNumber

                       excel.Range(BCELL).select
                       excel.activecell.formulaR1C1 = "'" + QTY

                       excel.Range(CCELL).select
                       excel.activecell.formulaR1C1 = "'" + PO

                       excel.Range(DCELL).select
                       excel.activecell.formulaR1C1 = "'" + LINE

                       excel.Range(ECELL).select
                       excel.activecell.formulaR1C1 = "'" + sch

                       excel.Range(FCELL).select
                       excel.activecell.formulaR1C1 = "'" + PLIST

                       excel.Range(GCELL).select
                       excel.activecell.formulaR1C1 = "'" + R_DATE


i = i + 1

Next n

c = Trim$(Str$(i))

ACELL = "A" + c
BCELL = "B" + c
CCELL = "C" + c
DCELL = "D" + c
ECELL = "E" + c
FCELL = "F" + c
GCELL = "G" + c



        RipNumber = .GetDisplayText(22, 6, 10)
        QTY = .GetDisplayText(22, 33, 6)
        PO = .GetDisplayText(22, 42, 10)
        LINE = .GetDisplayText(22, 53, 3)
        sch = .GetDisplayText(22, 57, 3)
        PLIST = .GetDisplayText(22, 61, 10)
        R_DATE = .GetDisplayText(22, 73, 8)


                       excel.Range(ACELL).select
                       excel.activecell.formulaR1C1 = "'" + RipNumber

                       excel.Range(BCELL).select
                       excel.activecell.formulaR1C1 = "'" + QTY

                       excel.Range(CCELL).select
                       excel.activecell.formulaR1C1 = "'" + PO

                       excel.Range(DCELL).select
                       excel.activecell.formulaR1C1 = "'" + LINE

                       excel.Range(ECELL).select
                       excel.activecell.formulaR1C1 = "'" + sch

                       excel.Range(FCELL).select
                       excel.activecell.formulaR1C1 = "'" + PLIST

                       excel.Range(GCELL).select
                       excel.activecell.formulaR1C1 = "'" + R_DATE


i = i + 1


        .TransmitTerminalKey rcIBMPf8Key
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1


        Loop

End With




End Sub





Aucun commentaire:

Enregistrer un commentaire