Excel/VBA - Running a Macro/Userform

Ask a question



Issue


I am a beginner in VBA programming and I have a worry in the execution of a macro from a user form.
  • I actually have 5 different worksheets, containing several macros attached to each of them. My goal is to create a user form with a button interface with spreadsheet so you can run the macro in the sheet I want I want. *My problem is I cannot assign to a button click (the user form) the execution of my target macro. (I do not know if this is clear ...)

Solution


The easiest way would be to put your macros in a public module by specifying the sheet on which you want to intervene.
Alternatively, declare your macro by Target.
  • Public Sub Test ()

In the Userform:
  • Private Sub UserForm_Click () Feuil1.Test 'or Sheets ("Sheet1"). End Sub Test

Note that


Solved by lermite222
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team