Results 1 to 9 of 9

How do I reset a for next loop in the script?

Threaded View

  1. #1
    Registered User
    Join Date
    10-15-2012
    Location
    Brawley, California
    MS-Off Ver
    Excel 2010, 2007
    Posts
    11

    Question How do I reset a for next loop in the script?

    Hello friends,

    I have a nested for-next loop inside another for-next loop, but when the nested loop ends it does not reset to the beginning again for the next item in my array loop. I am pretty sure the problem lies in my declarartions and how VBA handles arrays used in For-Next loops. I am having a mental block concerning declaring arrays and their ranges. An example of the setup is below;

    Dim simspg as variant
    Dim simspoint as variant
    simspg = Array("SP001", "SP002", "SP003", "SP004", "SP005", "SP006", "SP007", "SP008", "SP009", "SP010", "SP011", "SP012", "SP013", _
                           "SP014", "SP015", "SP016", "SP017", "SP018", "SP019", "SP020", "SP021")
    For each simspoint in simspg 
    For x = 1 to 100
    Worksheets (simspoint).select
    cells (x,1).value = 12
    next
    next
    How would I properly use these two for-next loops such that "x" is reset to 1 each time a new member of the array is called?

    Thanks for any help, Newbee BAT:-)
    Last edited by Cutter; 10-15-2012 at 05:36 PM. Reason: Added code tags

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