Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default After For..Next..Go to Next Row Data

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




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default After For..Next..Go to Next Row Data

Hi Junior,

Try changing:

For CurrentRow = 2 To 2


to:

For CurrentRow = 2 To NumOfRows

---
Regards,
Norman


"Junior728" wrote in message
...
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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Labels- POssible to show data value and data label together? kippers Charts and Charting in Excel 1 April 1st 09 01:33 PM
Increase Your Business By Data Conversion, Data Format and Data EntryServices in India Data Entry India Excel Worksheet Functions 1 March 31st 08 12:51 PM
Save 20% On Data Conversion and Data Formats Services by Data EntryIndia Data Entry India Excel Discussion (Misc queries) 0 March 31st 08 12:00 PM
Data Entry Online, Data Format, Data Conversion and Data EntryServices through Data Entry Outsourcing [email protected] Excel Discussion (Misc queries) 0 March 20th 08 12:45 PM
MULTIPLE DATA - How to insert new data into existing data.... Rodorodo Excel Discussion (Misc queries) 0 December 15th 06 11:50 PM


All times are GMT +1. The time now is 02:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"