After For..Next..Go to Next Row Data

J

Junior728

Hi All,

I have one problem that i encountered. The script below runs but always
stuck at Row A and does not proceed to row ..b..c..d..till end of Rows?
Where is that so? have i left out anything? Boss want me to do this within a
deadline but i still cannot figure out what's wrong? can someone help?

In my example, there are a coule of For..Next.. Cos they are different
groups of instructions for different rows..so i cannot use the same
instructions FOR ALL THE ROWS...=)

Thanks in advance!!!

See my example:

Sub SR()
'ENTR DI 0230735,231037 TESTING MACRO FOR STOCK ROTATION

DirMacro$ = "h:\"
MacroName$ = "StockRotation.srl"
Open DirMacro$ + MacroName$ For Output As #2
Print #2, "# Nexus - Script Recording Language"
Print #2,


Range("A2").Select
NumOfRows = Cells(Rows.Count, 1).End(xlUp).Row
CurrentRow = ActiveCell.Row + 1

For CurrentRow = 2 To 2
WH$ = ActiveSheet.Cells(CurrentRow, 1)
PART$ = ActiveSheet.Cells(CurrentRow, 2)
VENDOR$ = ActiveSheet.Cells(CurrentRow, 3)
PART_NO$ = PART$
CODE$ = ActiveSheet.Cells(CurrentRow, 4)
RMA$ = ActiveSheet.Cells(CurrentRow, 5)
Qty$ = ActiveSheet.Cells(CurrentRow, 6)
PRICE$ = ActiveSheet.Cells(CurrentRow, 7)


'FIRST LINE 01 'why it keep on looping the same part?VSJMEILING?
Print #2, "FunctionKey (HOME)"
Print #2, "TypeString ("; Chr$(34); "ENTROEVR0"; VENDOR$; ","; WH$;
Chr$(34); ")"
Print #2, "FunctionKey (ERASETOEOF)"
Print #2, "FunctionKey (ENTER)"
Print #2, "WaitFor (UNLOCK)"
Print #2, "WaitForCursorPos (1, 10)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
Print #2, "TypeString ("; Chr$(34); CODE$; Chr$(34); ")"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
'Print #2, "WaitForCursorPos (13, 9)"
Print #2, "TypeString ("; Chr$(34); PART$; Chr$(34); ")"
Print #2, "TypeString (TAB)"
'Print #2, "WaitForCursorPos (13, 37)"
Print #2, "TypeString ("; Chr$(34); Qty$; Chr$(34); ")"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
'rint #2, "WaitForCursorPos (13, 57)"
Print #2, "TypeString ("; Chr$(34); PRICE$; Chr$(34); ")"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Next CurrentRow

For CurrentRow = 3 To 3
'SECOND LINE 2
Print #2, "TypeString ("; Chr$(34); PART$; Chr$(34); ")"
Print #2, "TypeString (TAB)"
Print #2, "TypeString ("; Chr$(34); Qty$; Chr$(34); ")"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
Print #2, "TypeString ("; Chr$(34); PRICE$; Chr$(34); ")"
Print #2, "FunctionKey (PF12)"
Print #2, "TypeString (TAB)"
Next CurrentRow

For CurrentRow = 4 To NumOfRows

'New Page. How to loop this new Page for 7 times? Loop within Loop
'FIRST PART IN NEW PAGE
Print #2, "TypeString ("; Chr$(34); PART$; Chr$(34); ")"
Print #2, "TypeString (TAB)"
Print #2, "TypeString ("; Chr$(34); Qty$; Chr$(34); ")"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
Print #2, "TypeString ("; Chr$(34); PRICE$; Chr$(34); ")"
Print #2, "TypeString (BACKTAB)"
Print #2, "TypeString (BACKTAB)"
Print #2, "TypeString (BACKTAB)"
Print #2, "TypeString (BACKTAB)"
Print #2, "TypeString (BACKTAB)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"

'SECOND PART IN NEW PAGE
Print #2, "TypeString ("; Chr$(34); PART$; Chr$(34); ")"
Print #2, "TypeString (TAB)"
Print #2, "TypeString ("; Chr$(34); Qty$; Chr$(34); ")"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
Print #2, "TypeString ("; Chr$(34); PRICE$; Chr$(34); ")"
Print #2, "TypeString (BACKTAB)"
Print #2, "TypeString (BACKTAB)"
Print #2, "TypeString (BACKTAB)"
Print #2, "TypeString (BACKTAB)"
Print #2, "TypeString (BACKTAB)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"
Print #2, "FunctionKey (DOWN)"

'THIRD PART IN NEW PAGE
Print #2, "TypeString ("; Chr$(34); PART$; Chr$(34); ")"
Print #2, "TypeString (TAB)"
Print #2, "TypeString ("; Chr$(34); Qty$; Chr$(34); ")"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
Print #2, "TypeString (TAB)"
Print #2, "TypeString ("; Chr$(34); PRICE$; Chr$(34); ")"
Print #2, "FunctionKey (PF12)"
Print #2, "TypeString (TAB)"
Next


Print #2, "WaitFor (UNLOCK)"
Print #2, "FunctionKey (ENTER)"
Print #2, "WaitFor (UNLOCK)"
Print #2, "WaitForCursorPos (1, 10)"
Print #2, "# End script file"
Close #2
MsgBox ("MISSION COMPLETED!!!See StockRotation.srl")
Close
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top