+ Reply to Thread
Results 1 to 5 of 5

Run Macro in WB2 From WB1

Hybrid View

  1. #1
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,441

    Run Macro in WB2 From WB1

    .
    I've searched the Forum and a number of sites on the internet ... they all state the follwing method for running a macro in a different workbook :

    Application.Run ("'FSA-Spreadsheet2.xlsm'!CpyPasteSrPMQuery")
        
    Application.Run ("'FSA-Spreadsheet2.xlsm'!Module3.CpyPasteSrPMQuery")

    Neither of the above works. The error message received indicates the macro is not to be found.

    The macro name is correct .. the workbook name is correct. The other workbook is already open.

    The macro is located in Module3 of the "other workbook".


    The image demostrates what occurs in the remote workbook when attempting to run the macro remotely. Is there another method of running a macro in another
    workbook ?

    Thank you.




    Run Macro.jpg
    Last edited by Logit; 02-15-2019 at 08:01 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Run Macro in WB2 From WB1

    Something like the following perhaps.

    This is a macro in book1 which runs a macro called "mymacro" in another book2 which is open in memory

    Sub RunMacroInAnotherWorkbook()
        Dim wb As Workbook
    
        Set wb = Workbooks("book2")
    
        Application.Run "'" & wb.Name & "'!mymacro"
    
    
    End Sub
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,441

    Re: Run Macro in WB2 From WB1

    .
    Thank you Richard.

    It still fails as before. Frustrating.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,441

    Re: Run Macro in WB2 From WB1

    .

    Richard :

    Disregard my previous post. Not certain what occurred but your version does indeed work.

    Thank you.

    Please accept my apologies.

    Have a great evening !

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Run Macro in WB2 From WB1

    OK, glad to have helped.

+ 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] macro showing error ( macro not found ) while trying to execute macro every 1 minute
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2018, 07:58 PM
  2. [SOLVED] Define variable in macro than calling that macro inside another macro
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-21-2015, 10:58 AM
  3. Using a macro on workbook1 to create a button in wb2 and assigning macro "wb2!macro"
    By penfold1992 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2014, 11:39 AM
  4. [SOLVED] Macro to show Which macro didnt work in a nested macro
    By akhileshgs in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-10-2013, 03:21 AM
  5. Perform macro "on open" specific file- store macro in Personal Macro Workbook?
    By thompssc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2012, 12:38 PM
  6. lookup macro, solver macro, realtime macro
    By xelhelp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2011, 06:14 PM
  7. 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

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