+ Reply to Thread
Results 1 to 6 of 6

Pause macro, select file, continue macro

Hybrid View

  1. #1
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58

    Pause macro, select file, continue macro

    I am really not quite sure how best to word this, which I imagine is why I can't find it on a search engine.

    I have two macros that I wish to run in sequence, but the two documents involved are not the same every day.

    What I have put together so far (with a lot of help from RoyUK, whom I owe a few pints should I ever come across him) is I open the first document, and run macro 1. Macro 1 will do everything I want it to and will then take me to the correct folder to find the next file. I double click on the correct file to open it and then run macro 2 to do everything else.

    I am wondering if it is possible to combine these two. That when I double click the file I want, it carries on with the macro rather than having to start a new one.

    Is that realistic?

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    It is possible

    Withou seeing your macro code I can not advice the best way to do it

    1 option is have a 3rd macro that calls the other 2

    Sub MyMainMacro()
        Call Macro1
        Call Macro2
    End Sub
    Another option is to have macro1 call macro2 by placing a call command before the End Sub

    A 3rd option is to combine the 2 macros codes into 1 macro
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Add a macro to run the two macros

    Sub doIt
    Macro1'opens workbook
    Macro2
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58
    Combining the two macros would be easy if it weren't for the fact I have to manually select and open the second workbook to continue.

    I have already learned how to open a second spreadsheet automatically and the macro happily carrying on, but I have not yet worked with a macro that requires me to do something mid-macro.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Quote Originally Posted by DamienC
    Combining the two macros would be easy if it weren't for the fact I have to manually select and open the second workbook to continue.

    I have already learned how to open a second spreadsheet automatically and the macro happily carrying on, but I have not yet worked with a macro that requires me to do something mid-macro.
    If you do what we said and reeplace macro1 with the one that allows you to select the file, that macro will run to the end then the next macro will run.

  6. #6
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58
    Sorry Roy, I missed your post before replying. Running the one macro that starts both does indeed work very well. Never imagined it being that easy.

+ 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