+ Reply to Thread
Results 1 to 7 of 7

variables not updating in embedded loop

  1. #1
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    variables not updating in embedded loop

    After I import a data table that has start, arrival, and departure times assigned to vehicles, I want to find those times in a time table I created that has 1440 columns for every minute of the day. So my outer loop is looping through the data table line by line to assign the time values. The inner loop is supposed to find the cells with the matching values in my time table. Its accurate for the first loop, but the subsequent loops are not finding the right cells even though I know the outer loop is updating the values from the data table. To be more clear, the "1" variables are updating correctly, but the "2" variables are not. What am I missing? Thanks! -Luke
    Please Login or Register  to view this content.

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: variables not updating in embedded loop

    Cells rowindex is a Long value, not a String value like you are using.

    So instead of "8" just put 8.

    That's the first thing that comes to my mind. Otherwise post a small sample workbook to test.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: variables not updating in embedded loop

    A sample is uploaded.
    stime2 columns should be: pe, qa, vv, wz, xi, aef
    atime2 columns should be: pj, tr, wr, xb, ady, afm
    dtime2 columns should be: qa, vv, wz, xi, aef, afu
    After the first loop, its seems like its hit or miss if the values will be updated or not. Could it be a processing error? 1440 columns is too much to loop through? Thanks again. -Luke
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: variables not updating in embedded loop

    It seems to work better only when I manually find the values I need in the time table using ctrl-f. Then the embedded loop will seem to find the corresponding value in the time table. But this is not a realistic solution and I have no idea why this makes it work better.

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,604

    Re: variables not updating in embedded loop

    Please Login or Register  to view this content.
    Last edited by protonLeah; 07-22-2019 at 12:24 AM.
    Ben Van Johnson

  6. #6
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: variables not updating in embedded loop

    Proton - Thanks for the revised code. However, I'm still having an issue with a few of the "2" variables not updating to the corresponding time values. Its just like Excel refuses to acknowledge the value in the time table cells until I do a ctrl-f to expose it. This wasnt supposed to be this hard...

  7. #7
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: variables not updating in embedded loop

    I couldnt solve why my inner loop wasnt finding the values in my time table, so I resorted to recording a macro to use "find" and it works like a charm. So, not exactly solved, but solved. -Luke
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Embedded Excel Object - Updating Formulas
    By bradlehoux in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-02-2018, 04:11 PM
  2. Calling A Function With Variables based A Loop Within A Loop
    By Mark123456789 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-24-2016, 03:03 PM
  3. [SOLVED] Embedded loop
    By Sgligori in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-09-2016, 10:04 AM
  4. Loops with saved variables for each loop to be compared after loop is finished?
    By flabb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2016, 07:48 AM
  5. Embedded images in outlook email not updating
    By derpygoat in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-30-2014, 01:25 PM
  6. [SOLVED] Macro Button With Embedded Variables
    By Forex-Forex in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-26-2014, 03:07 PM
  7. 2 Embedded & Linked Excel Spreadsheets in Word Not Updating after I press "save"
    By grapesofwrath in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2009, 01:43 AM

Tags for this Thread

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