+ Reply to Thread
Results 1 to 4 of 4

How do I prevent variable from getting cleared before completing loop

  1. #1
    Registered User
    Join Date
    07-05-2018
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    26

    How do I prevent variable from getting cleared before completing loop

    I'm getting a runtime error 75 file/path access error due to the script "forgetting" the filepath name stored in ReadTextFile

    The file being read looks something like this:
    Please Login or Register  to view this content.
    Sheet1 looks something like this:
    Please Login or Register  to view this content.
    And the script is as follows:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: How do I prevent variable from getting cleared before completing loop

    You have this line

    Please Login or Register  to view this content.
    That does not skip to the next file... to do that change that line to

    Please Login or Register  to view this content.
    and add this to just before your Next FileCell line:

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    07-05-2018
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    26

    Re: How do I prevent variable from getting cleared before completing loop

    That didn't quite fix it, but I understand better why the script is failing, so I'm going to play with it some more to see if I can figure it out on my own. (Columns A through E have values, and some of those columns are longer than column D, so it's pulling the filename/path from a blank cell)

    Thanks!
    Last edited by Wiigit; 10-05-2023 at 04:30 PM.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: How do I prevent variable from getting cleared before completing loop

    Your filepath variable is used exactly once, so I don't see any possibility of it being erased or forgotten....

+ 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. finding cell value and completing loop based on that
    By ammartino44 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-02-2015, 08:06 PM
  2. [SOLVED] How to prevent certain cells from being deleted when page is cleared
    By behnam in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-23-2013, 01:17 PM
  3. A Loop not completing
    By sgarciareilly in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-17-2013, 07:07 PM
  4. Loop only completing first loop
    By jcommins in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2013, 01:08 PM
  5. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM
  6. For Loop not completing
    By somnath.deb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-01-2011, 11:55 PM
  7. How do I prevent Crtl+End moving to a cleared cell?
    By Ralph in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-04-2006, 06:35 AM

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