+ Reply to Thread
Results 1 to 2 of 2

Macro runs while in focus of targeted workbook but out-of-range once I change of wb

  1. #1
    Forum Contributor
    Join Date
    05-17-2016
    Location
    Montreal
    MS-Off Ver
    2013
    Posts
    115

    Macro runs while in focus of targeted workbook but out-of-range once I change of wb

    Hey,

    I've been lurking the forums and the web but have yet to find how to solve this..
    The code as it stands looks like this, in a module:
    Please Login or Register  to view this content.
    This works as long as my MarketTracker.xlsm/MarketTrack(sheet) is in focus, though as-soon-as I change of workbook it throws me an error "out-of-range" (I'm assuming it's because the macro is trying to run the My_Procedure but it's no longer in the right place...) That said, all my workbooks (excel-files) are open at all times.

    Is there a way to get the Macro to always run on a specific workbook/worksheet in the background?

    Thanks for your time!

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Macro runs while in focus of targeted workbook but out-of-range once I change of wb

    - avoid selecting the sheet and the problem should vanish
    - used next row instead of last row - calculate once instead of several times (changed variable name to match)

    Try this method (untested) ..
    Please Login or Register  to view this content.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

+ 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] Ensuring that VBA code runs on records in a targeted Excel Worksheet
    By patdools in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-27-2019, 05:08 PM
  2. Macro runs when header / footer change
    By Dturazza in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-26-2018, 05:12 AM
  3. Variables values change after macro runs
    By chriska416 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-26-2016, 06:47 PM
  4. Mouse Focus Changes After Script Runs
    By ClivePoole in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-12-2008, 02:45 AM
  5. Change cell value and macro runs
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-23-2007, 04:18 AM
  6. Cell value change runs a macro?
    By Steach91 in forum Excel General
    Replies: 6
    Last Post: 06-18-2006, 03:20 PM
  7. Run macro when excel workbook gains focus
    By Perry in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-31-2006, 07:45 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