+ Reply to Thread
Results 1 to 3 of 3

Stop a Function from Running

  1. #1
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Stop a Function from Running

    I have a subroutine, SnapshotList that should get a list of files from a directory. However its DIR() statement is "hijacked" by a function called FileExist. Here is the code:

    Please Login or Register  to view this content.
    SnapshotList runs OK up to this line: Shtu.cells(RowNumS, "D") = FileName.

    At that point execution jumps to FileExist and since it also uses DIR(), the FileName = DIR() statement in SnapshotList returns "" and execution stops.

    What is calling FileExist? How do I stop FileExist from running?

    I would post the workbook, but there is way too much proprietary information to sanitize it.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Stop a Function from Running

    Is the FileExist function being used as a formula in a cell that refers to Shtu.cells(RowNumS, "D")? I'd suggest setting calculation to manual while you run the SnapshotList code.
    Rory

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Stop a Function from Running

    FileExist does is not used in the range referred to in other macro. However, it exists on shtU. That's probably enough to get it going. I think I will run a test with it on another sheet.

    I tried your recommendation and it worked.

    However, I used a different logic to get around it. I use snapshot list to generate a list, for my users to see, of file snapshots available. I use data validation against this list to make the selection of a file name so they can only pick a file that exists. I also back this up with a ISNUMBER(MATCH()) on the selected file name and check that flag in case they override the validation.

    Interesting situation. You gave me the clue as to what may have caused it and how to fix it, which is good in case I see a similar situation in the future.

+ 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. VBA to stop running after certain date
    By michael35 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-03-2020, 03:54 AM
  2. How to stop function running
    By Theodjinn in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 07-04-2017, 11:14 PM
  3. [SOLVED] Event Driven Macros stop running after running a routine macro
    By ChemistB in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2017, 12:34 PM
  4. Stop Function From Running
    By realniceguy5000 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-13-2011, 05:04 PM
  5. VBA won't stop running
    By codsmith in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-03-2011, 09:39 AM
  6. Macro stop running
    By schnett in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-10-2008, 04:01 PM
  7. How do I stop a Macro from running?
    By JulianB in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-10-2006, 05:40 PM

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