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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.