+ Reply to Thread
Results 1 to 6 of 6

Running Macros More Than Once.

  1. #1
    Forum Contributor
    Join Date
    11-30-2020
    Location
    Ny
    MS-Off Ver
    Office 365
    Posts
    173

    Running Macros More Than Once.

    I have a folder that contains several workbooks. I can run the macros that call information from one workbook to another with no issue, however, if I run them several times a debug error occurs, If I exit excel and reopen the workbook it runs just fine, can anyone explain to me why this happens. Thanks......

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Running Macros More Than Once.

    What macros? What error(s)? What happens? What doesn't happen? Is the file/data corrupted? What does "several times" mean? Twice? Three times? Lots of times? Why are you running the macros more than once? Is it intentional? If it is, what should happen?

    When it goes into debug mode, what line of code is highlighted? What's that line of code trying to do? Are there any ranges, cells, variables? What values do they have? What values should they have?

    Bear in mind that you know what your folder structure looks like and what folders are in it. We don't. Are you running the macro(s) several times with different files?

    Maybe you need to reset some variables, or arrays, or counters when the macro completes. Are you closing the files?

    Are the macros in a "master" workbook that you open and then process pairs of files? What is the "process" meant to do?
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    11-30-2020
    Location
    Ny
    MS-Off Ver
    Office 365
    Posts
    173

    Re: Running Macros More Than Once.

    Sorry, I should have been more specific. All the macros copy numeric and text values from one workbook and paste the info to another workbook or in some cases two workbooks. The debug error is in the highlighted line y.Sheets("Week 01").Range("C10").Copy ------ Now if I close the debug screen, close the workbook, close excel then reopen and run the macro again it works just fine. Now it happens in various macros residing in different workbooks but the debug error is always in the copy command.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Running Macros More Than Once.

    You don't say what the error is. If it's, say, subscript out of range, that might imply that the "Week 01" worksheet wasn't present in workbook "y". If it's Object required, that could mean workbook "y" has been closed. Range("C10") shouldn't be a problem.

    Is that the full line of code? What is the error message? Is there an error number?

    In the Immediate Window . . .

    If you type "?y.Name" (without the quotes), what do you see?

    If you type "?y.Sheets("Work 01").Range("C10").Value" (again, no quotes), what do you see?
    Last edited by TMS; 02-20-2024 at 08:16 PM.

  5. #5
    Forum Contributor
    Join Date
    11-30-2020
    Location
    Ny
    MS-Off Ver
    Office 365
    Posts
    173

    Re: Running Macros More Than Once.

    Sorry i didn't gat back to you sooner, I was called out of town. However the ENTIRE problem was me, I had another command going to a different workbook. I can't thank you enough for your time! Thank you again!!!

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Running Macros More Than Once.

    You're welcome. Thanks for the rep.

+ 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. All Macros Are Enabled, But Macros Are Still Not Running
    By chasfh in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 06-04-2019, 07:23 AM
  2. [SOLVED] Two macros are running separately but they are not running at once
    By RavindraK in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-18-2018, 11:51 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. [SOLVED] Hiding the file when running macros and after running macros
    By thilag in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-10-2016, 07:15 AM
  5. Running two macros as one
    By Seraph84 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-11-2011, 01:48 AM
  6. Running Macros
    By Dastard in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2006, 11:51 PM
  7. Running Macros
    By in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2006, 04:19 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