Using Userforms To Call Macros

DataBlake

Well-known Member
Joined
Jan 26, 2015
Messages
781
Office Version
  1. 2016
Platform
  1. Windows
Hello all,
The title pretty much says it all but i have a list of macros that i want to correlate to a userform using the tick boxes, but for the life of me i don't understand the userform part of VBA. Can someone help me create a userform that will compile a list of macros to call? lets say

Code:
"Please select your desired functions"

Option1 
Option2
Option3...

and depending on their selection it grabs those specific macros in order that they are presented?

Option1:
Code:
   Call ATSfigures
   Call boltFIX
   Call partLOOK

Option2:
Code:
   Call deleteBLANK
   Call otoqLOOK
   Call CharacterLimit

Option3:
Code:
   Call updateMS
   Call Workaround
   Call obscureFILTER

so if someone selects options 1 & 3 it would compile like

Code:
   Call ATSfigures
   Call boltFIX
   Call partLOOK
   Call updateMS
   Call Workaround
   Call obscureFILTER
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Code:
If Checkbox1.Value = True then
            Call ATSfigures
            Call boltFIX
            Call partLOOK else
          If Checkbox2 . Value = True then
            Call deleteBLANK
            Call otoqLOOK
            Call CharacterLimit
          End If

        If Checkbox3.Value = True then
           Call updateMS
           CallWorkaound
           Call obscureFILTER
        End If
 
Upvote 0
Code:
If Checkbox1.Value = True then
            Call ATSfigures
            Call boltFIX
            Call partLOOK else
          If Checkbox2 . Value = True then
            Call deleteBLANK
            Call otoqLOOK
            Call CharacterLimit
          End If

        If Checkbox3.Value = True then
           Call updateMS
           CallWorkaound
           Call obscureFILTER
        End If

and where do i put this exactly?
this is my progress so far
BqL7wk5.png


I'm awfully confused on how to change the text of the checkboxes, as well as how to connect the code to the corresponding parts of it.
and then theres the okay button which i assume is a command button, but howwwww do i make it an okay button?
sorry for being so lost on userforms but everything i read is needlessly complicated for my small brain
 
Upvote 0
and where do i put this exactly?
this is my progress so far
I'm awfully confused on how to change the text of the checkboxes, as well as how to connect the code to the corresponding parts of it.
and then theres the okay button which i assume is a command button, but howwwww do i make it an okay button?
sorry for being so lost on userforms but everything i read is needlessly complicated for my small brain

Update: i found out how to change the names of checkboxes and other items added by the toolbox, still don't know how to correlate code to the userform.
 
Last edited:
Upvote 0
okay so now i have a form called "Processes"
and a sub in there

Code:
Sub userWP()

If CheckBox1.Value = True Then
End If
            
If CheckBox2.Value = True Then
   Call ATSwheelpros
   Call boltFIX
   Call partLOOK
   Call finishLOOK
   Call deleteBLANK
   Call otoqLOOK
End If

If CheckBox3.Value = True Then
           Call CharacterLimit
End If

If CheckBox4.Value = True Then
           Call updateMS
End If

If CheckBox5.Value = True Then
           Call Workaround
End If

If CheckBox6.Value = True Then
           Call obscureFILTER
End If

End Sub

now i just need the userform to show whenever someone double clicks on a cell

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

If Target.Address = "$D$2" Then

   Processes.Show
   Sheets("Program Start").Select

End If
End Sub


so what am i getting wrong here?
the userform pops up and everything doesn't work.
its just there.... indefinitely ... like a monument to my failure of these tutorials
 
Upvote 0
Insert a command button on the form and put the userWP sub into the command button click event. When you insert the command button onto the userform in the VBA editor double click the button, this will then open the click event for it, just cut and paste the sub into there, or you could just put in 'Call userWP' instead.
 
Upvote 0
Insert a command button on the form and put the userWP sub into the command button click event. When you insert the command button onto the userform in the VBA editor double click the button, this will then open the click event for it, just cut and paste the sub into there, or you could just put in 'Call userWP' instead.

Awesome thank you!
you've been very helpful.
I just have one last question.
Is there a way to show the same userform but call different macros?
So lets say someone does the double click in D2 and it runs the macros from userWP
Then have an option to double click E2 and it shows the same userform, but runs the macros from userMHT
or do i just have to copy the userform each time i want to have a different outcome?
 
Upvote 0
I'm also currently researching how to make certain checkboxes mandatory as well:

rules:
checkbox 1 or two must be check
if checkbox 1 is checked none of the others can be checked

EDIT: I guess i would be changing to option buttons in this case
 
Last edited:
Upvote 0
So far (with checkboxes):
I have it to where if you select checkbox 1 it blocks all of the other checkboxes
If you select checkboxes 3-6 it will automatically select checkbox 2

I need it so that if anything is checked in 3-6 and they uncheck 2 it will display an error and not run the macros
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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