+ Reply to Thread
Results 1 to 7 of 7

#REF error happened at RANDOM when running a macro?

  1. #1
    Registered User
    Join Date
    07-10-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    77

    #REF error happened at RANDOM when running a macro?

    One of my coworkers was using a macro I created and found an error that neither I, or he, could replicate after the fact.

    The idea is that I have a range of numbers in one worksheet that I want to multiply by a fraction and paste them in another worksheet. There are a couple ways of doing this (most notably the simple copy/paste special method) but for whatever reason when I wrote this last year I did it by using the Evaluate function.

    Here is a simplified version of what was happening. Instead of displaying the new values on the 2nd worksheet, it showed the #REF problem. I also want to note that when he ran it, it worked perfectly for 18/19 iterations of a loop that I have it in, and like I said before, we couldn't replicate it for any iterations when I tried again today. This leads me to believe that maybe he was mutli-tasking and pressing something else on the keyboard that may have affected it. This was the case for a different macro we have - when a user was pressing "Shift" to type an email, which caused the sub to stop because it was trying to open a workbook with an Open Event but holding down shift prevents that from working.

    Please Login or Register  to view this content.
    Last edited by dmasters4919; 05-21-2015 at 12:22 PM.

  2. #2
    Registered User
    Join Date
    07-10-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: #REF error happened at RANDOM when running a macro?

    I think I figured it out. I believe it was because he activated another workbook while it was running

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: #REF error happened at RANDOM when running a macro?

    Great, I might suggest adding not just a sheet reference in the code but also a workbook reference, if this is a common scenario.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  4. #4
    Registered User
    Join Date
    07-10-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: #REF error happened at RANDOM when running a macro?

    After thinking more about this I was only actually able to recreate this in debug mode, when I activated a new workbook before using the Evaluate method. I can't figure out how he even activated a different workbook while the macro was running. Is that even possible?

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: #REF error happened at RANDOM when running a macro?

    sure you can usually do stuff while macro runs... could click on the taskbar for example and activate even a totally different instance of excel.. alt-tab would also switch... lots of things like that can happen

  6. #6
    Registered User
    Join Date
    07-10-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: #REF error happened at RANDOM when running a macro?

    Quote Originally Posted by Arkadi View Post
    sure you can usually do stuff while macro runs... could click on the taskbar for example and activate even a totally different instance of excel.. alt-tab would also switch... lots of things like that can happen
    Hmmmm...I'm not able to do this at all on my computer. It won't recognize the switch

  7. #7
    Registered User
    Join Date
    07-10-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: #REF error happened at RANDOM when running a macro?

    Quote Originally Posted by Arkadi View Post
    sure you can usually do stuff while macro runs... could click on the taskbar for example and activate even a totally different instance of excel.. alt-tab would also switch... lots of things like that can happen
    I take it back...you're right, when I have a lot of workbooks open there are times it will let me switch workbooks while a macro is running. Thanks!

+ 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. Macro stops at random places and no error message
    By David A Coop in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-16-2014, 08:30 PM
  2. Macro that creates duplicate sheets. Random Error.
    By timmtamm in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-07-2011, 12:25 PM
  3. Pause a random number generator while running a macro
    By healtheplanet in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-13-2010, 04:04 PM
  4. Cannot find macro error when running a macro from a macro in a diffrent workbook.
    By Acrobatic82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2010, 09:22 AM
  5. #NAME? error when using IFERROR what happened?
    By AnnaV in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-14-2009, 12:21 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