+ Reply to Thread
Results 1 to 6 of 6

Macro stops executing if another workbook is open

  1. #1
    Registered User
    Join Date
    01-25-2013
    Location
    Bosnia and Herzegovina
    MS-Off Ver
    Excel 2010
    Posts
    35

    Macro stops executing if another workbook is open

    Title says it all.
    I've got an excel which autorefreshes every 10 minutes,with new data imported.I've made a macro that saves old data once new one is imported.
    But,if i have another excel file opened at the moment of the autorefresh,macro module is going to stop executing,thus not saving old data from web query that is autorefreshing.

    This is the module in question:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Debugger highlights the part when module selects Q1 range

    I'm guessing that the thing that happens is that,once module gets to "select Q1" part,it tries to select it in active workbook,and not the workbook that contains that code.
    So,if i got some other excel file opened,that is not related to autorefreshed one,its gonna try to copy data from autorefreshed excel onto that new excel.

    HOw could i fix it?
    I beleive i need some method of telling macro that he should seek Q1 in that specific workbook,rather than active one.
    But,alas,i'm not good with coding,so help is needed(and appreciated)

    Thanks in advance

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro stops executing if another workbook is open

    HAve you tried inserting
    Please Login or Register  to view this content.
    in your code??
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    01-25-2013
    Location
    Bosnia and Herzegovina
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Macro stops executing if another workbook is open

    No.
    I don't posses knowlenge required to corectly insert it(or most of other codes).
    I can check other codes,figure out how they work then use some parts of them and modify them.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro stops executing if another workbook is open

    avoid selecting
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Registered User
    Join Date
    01-25-2013
    Location
    Bosnia and Herzegovina
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Macro stops executing if another workbook is open

    Quote Originally Posted by JosephP View Post
    avoid selecting
    Please Login or Register  to view this content.
    Yes,it helped.I added rep.
    However,now that module1 is fixed,i'm getting the debug in main code part

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Could you please,modify this one too?

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Macro stops executing if another workbook is open

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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