Results 1 to 15 of 15

Thread: Running a Macro on another worksheet

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,899
    Location
    Quote Originally Posted by simora View Post
    Paul_Hossler
    What transpired before that is that the user had selected the other workbook, so the other remote workbook was selected and therefore became the Active Workbook.
    Hope that makes sense.

    I sort of follow


    From post #1 ..

    Running a Macro on another worksheet (Assume you meant 'Workbook')
    
    
    I am trying to run a Macro on a different WorkBook.
    It wasn't clear to me (at least) which WB had the macro and which WB the macro was intended to operate on

    Since this works, I assumed that the WB 'Search Database 2025 test.xls' contained the macro RedFont

    This works: Application.Run ("'Search Database 2025 test.xls'!RedFont")

    What I missed was some how activating the macro containing WB, either manually or in code

    Workbooks("'Search Database 2025 test.xls'").Activate
    which as you said then makes Search Database 2025 test.xls the ActiveWorkbook in

     ol2 = ActiveWorkbook.Name
    Workbooks(ol2).Application.Run ("!RedFont")
    Last edited by Paul_Hossler; 02-16-2025 at 07:34 PM. Reason: Futzing around for clarity
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •