Results 1 to 20 of 21

Thread: VBA Application.Run for Running Macros-with-Parameters Stored Inside an Excel Cell

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,954
    Location
    These forums makes it easy to get clear help. The best way is to attach a simple example file. Click the Go Advanced button on lower right of a reply box. Then click the Manage Attachments below that reply box.

    One critical thing that is often overlooked is the Module name. Sometimes one also needs to Run a macro from another workbook. In that case, we would add that but since you did not say that, I did not explain or show that.

    Here is a short example where both work for me. Normally, I use more distinctive module names than Module1.
    Sub Test_Run()  
      Application.Run "Module1.Run1", Worksheets(2)
      Application.Run "Module1.Run2", Worksheets(2).Name
    End Sub
    
    
    Sub Run1(ws As Worksheet)
      MsgBox ws.Name
    End Sub
    
    
    Sub Run2(wsName As String)
      MsgBox Worksheets(wsName).Name
    End Sub
    Last edited by Kenneth Hobs; 05-14-2021 at 09:03 AM.

Tags for this Thread

Posting Permissions

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