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. #16
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,954
    Location
    You only have one valid value, the name of the macro, to parse out. You had already created the other two inputs.

    Sub SelectAppsToRun()  
      Dim rng As Range, ws As Worksheet, txtctl As MSForms.TextBox
      
      Set ws = ThisWorkbook.Worksheets("Macro List")
      Set txtctl = TxtBoxSht.OLEObjects("TextBox1").Object
       
      For Each rng In MacroListSht.ListObjects("MacrosTable").ListColumns(2).DataBodyRange
        Application.Run Split(rng, ", ")(0), ws, txtctl
      Next rng
    End Sub
    
    
    Sub DisplayNameofTextBox(ws As Worksheet, activeTbx As MSForms.TextBox)
        MsgBox ws.Name
        MsgBox activeTbx.Name
    End Sub
    Use Paul's file to achieve your goal.

    Unless you know that the inputs will always exist, you will want to add error handling code for missing things like macro, worksheet, and textbox.
    Last edited by Kenneth Hobs; 05-15-2021 at 08:12 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
  •