+ Reply to Thread
Results 1 to 7 of 7

why is this code returning error AFTER it completes

  1. #1
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Question why is this code returning error AFTER it completes

    I have a code which acts as a macro for a specific range of cells, that when double clicked - open up a file location which allows user to select multiple files to open.

    it all works : however.

    if I chose not to select a file and cancel the box.. it does this? see attached.

    is there a problem with the code. see below?


    Please Login or Register  to view this content.
    Attached Images Attached Images
    Last edited by Muzza86; 04-24-2014 at 09:24 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,982

    Re: why is this code returning error AFTER it completes

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    04-24-2007
    Location
    NYC
    MS-Off Ver
    2k3/2k7/2010
    Posts
    270

    Re: why is this code returning error AFTER it completes

    You have to write in what to do if an user opts not to select any file.

  4. #4
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: why is this code returning error AFTER it completes

    could you kindly give me an example line of code of how to do that and where to put it? thanks

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,300

    Re: why is this code returning error AFTER it completes

    Try changing it to:
    Please Login or Register  to view this content.
    Anyone who confuses correlation and causation ends up dead.

  6. #6
    Forum Contributor
    Join Date
    04-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: why is this code returning error AFTER it completes

    thanks both of you. works fine now

  7. #7
    Forum Contributor
    Join Date
    04-24-2007
    Location
    NYC
    MS-Off Ver
    2k3/2k7/2010
    Posts
    270

    Re: why is this code returning error AFTER it completes

    your "Which" does not have an array of workbooks in it if the user opts not to select a file, this will cause a problem to your For loop. You need to tell system to check if the which is empty and skip the for loop if your "which" does not have an array of workbooks.

+ 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] Nested IF statements are returning FALSE values - cannot find error in code!
    By apex_chio in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-03-2013, 11:01 PM
  2. vba code returning Run Time Error 1004 method 'undo' of object
    By Ironman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-24-2012, 08:17 PM
  3. Excel 2007 : VBA Code returning error
    By jchessher in forum Excel General
    Replies: 3
    Last Post: 04-11-2011, 11:59 PM
  4. Code returning error 400
    By reggie1000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-10-2009, 05:53 AM
  5. Emailing a wsheet after some code completes
    By jsmity in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-30-2007, 10:59 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