Application.Run Calling subroutine in a UserForm with a variable

Carl2000

New Member
Joined
Jul 26, 2022
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
Good evening
I am using Excel 2019 and have a UserForm named UserForm 1.

I wish to run a subroutine stored in the UserForm using a variable created in another subroutine in the UserForm. eg.

Option Explicit
Public Test As String

Private Sub1()
Test = "Sub2"
Application.Run Test
End Sub

Private Sub2()
' Subroutine actions
End Sub

I can use Application.Run to run a subroutine called Sub 2 in Module 1 but can't figure out how to run it in my userform code.

Unfortunately I wasn't able to work it out from previous posts on this forum.

Many thanks
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi Carl2000 and Welcome to the Board! You can run the Sub2 from the userform Sub1 code by placing Sub2 in a module and designating it as a public sub (ie. Public Sub2). HTH. Dave
 
Upvote 0
Solution
Hi Carl2000 and Welcome to the Board! You can run the Sub2 from the userform Sub1 code by placing Sub2 in a module and designating it as a public sub (ie. Public Sub2). HTH. Dave
Many thanks for your assistance
 
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,566
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top