I know this probably absurd, but I've been playing with this for two days now and I think I've just burned out on it and I'm not seeing the obvious somewhere. I'm getting the default Attachmate Editor error message on compile "For and Next statements must be in same block" and I have access to no other VB debugger tools and the help is disabled on the company Macro Editor. I have Ultra Edit and Notepad2 to use so I'm hoping someone can put another set of eyes on this code and tell me where I've botched the For statements.
Again, I'm prepared for my beating as I know this is something obvious I've missed, but help an old guy out? The only thing I edited out was the actual values in the 'y' For statement that I'm writing to the spreadsheet as there is several hundred lines of just assigning values and writing them to the row(s) in the spreadsheet. I called out this section with the "****" line... btw, "x" "y" and "r" are all dimmed Global as Long (reused throughout the code in different Subs.
If you bring that sentence in for a fitting, I can have it shortened by Wednesday!
Again, I'm prepared for my beating as I know this is something obvious I've missed, but help an old guy out? The only thing I edited out was the actual values in the 'y' For statement that I'm writing to the spreadsheet as there is several hundred lines of just assigning values and writing them to the row(s) in the spreadsheet. I called out this section with the "****" line... btw, "x" "y" and "r" are all dimmed Global as Long (reused throughout the code in different Subs.
Code:
Sub Incoming
rowcount = 2 'Start at second line on Incoming spreadsheet
For r = 2 To MyRange.Rows.Count + 1 'NOTE: we are using Sheet 1 column A to do the loops for the dates!
'Move to DATE field
Call WaitScreen
Do Until (SCR.WaitForCursor(22, 33))
SCR.MoveTo 22, 33 'Move the cursor
Loop
Sess.Screen.PutString DT.Rows(r).Value, 22, 33 'Write the first date field desired
Call PressEnter
Call WaitScreen
'ERROR CHECK DATE ROUTINE
If SCR.Search("<< DATE NOT FOUND >>") = "<< DATE NOT FOUND >>" Then
'We know this date does not exist so skip the row
Goto Error4 'Go to next r
Else
'DATE IS VALID: CONTINUE RUNNING
End If
IsCheck = Trim(Sess.Screen.GetString(17, 47, 2))'Incoming Returns Count
If IsCheck = "0" Then
Goto Error4 'Go to next r there are no transmittal errors for this date
Else
'There exists Incoming Returns: continue running
End If
Do Until (SCR.WaitForCursor(17, 35))
SCR.MoveTo 17, 35 'Move the cursor to the question mark
Loop
Call PressEnter
'collect child screens
For x = 12 to 16 'numbers of the lines to check
'Reject Selection Screen
Dim IncomingRejCnt As String
IncomingRejCnt = Trim(Sess.Screen.GetString(x, 18, 02))
If IncomingRejCnt = "0" Or IncomingRejCnt = "" Then
'Go to next x as there are no "currently on file" records to capture
Goto NextX
Else
'Gather child pages
Do Until (SCR.WaitForCursor(x, 02))
SCR.MoveTo x, 02 'Move the cursor to the line
Loop
Call PressEnter
IncomingRtns.Select 'select the spreadsheet to write to
'We now have to parse through the sub categories
For y = 12 to 17
Dim cntme As Long
cntme = x 'using this as the variable within y to get back to the right x row when cycling through the loops
Dim CurntOnFile As String
CurntOnFile = Trim(Sess.Screen.GetString(y, 19, 02))
If CurntOnFile = "0" Then
'do nothing we don't collect that line
Goto NextY
Else
'Collect that line
Do Until (SCR.WaitForCursor(y, 02))
SCR.MoveTo y, 02 'Move the cursor to the line
Loop
Call PressEnter
'********************************************************************
'Code to collect child pages here
Do
'Variable allocation Note: reusing variables whenever possible!!!
StartPage = Trim(Sess.Screen.GetString(23, 63, 04))
LastPage = Trim(Sess.Screen.GetString(23, 75, 04))
rowcount = rowcount + 1
'Determine if we are at the last page
If StartPage = LastPage Then Exit Do
Call PressEnter 'Otherwise advance the page
Loop
'********************************************************************
End If
'There is no shortcut key back to the "y" category selection screen.
'We must therefore go all the way back to the "x" screen and work our way back down
Call PressF5
Do Until (SCR.WaitForCursor(cntme, 02))
SCR.MoveTo cntme, 02 'Move the cursor to the x line
Loop
Call PressEnter
'We are now back at the y screen
'next y line check
NextY:
Next y
Call PressF5 'Go back to the x screen
NextX:
Next x
'Done collecting all child pages.
Call PressF3
Error4:
Next r 'Loop, Change Date and do it again
End Sub
If you bring that sentence in for a fitting, I can have it shortened by Wednesday!