Excel Form Control to Run UserSub

I have some beautiful code written by Martin Liss which executes formatting rules against a spreadsheet. I created a FormControl and have been attempting to Record a Macro where I click the RunSub/UserForm in the VBA Editor window. Apparently the action is not recordable. Could someone point me toward the code to pass to allow this "button" to perform the RunSub action?

Thank you!
JohnD
LVL 1
John DarbyPMAsked:
Who is Participating?
 
Martin LissOlder than dirtCommented:
If you want to call the sub from a command button on the UserForm then do this

Private Sub CommandButton1_Click()
TheNameOfMySubInAModule ' Or Call TheNameOfMySubInAModule
End Sub

Open in new window

0
 
John DarbyPMAuthor Commented:
Marty,

I have this:

Sub RunSub()
Call ColorByIndentLevel
End Sub

When it says Sub or Function not defined and higlights the first line, how do I define it? :)
0
 
Martin LissOlder than dirtCommented:
Please post your workbook.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
John DarbyPMAuthor Commented:
Marty,

I just referenced the Sub you created for me directly and bingo the button work like a charm! Thank you!
0
 
Martin LissOlder than dirtCommented:
In your command button's Click event put just Call ColorByIndentLevel If that sub is in a module it should work.
0
 
Martin LissOlder than dirtCommented:
Once again, you're welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.