Avatar of John Darby
John Darby
Flag for United States of America asked on

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
Microsoft ExcelVBA

Avatar of undefined
Last Comment
Martin Liss

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Martin Liss

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
John Darby

ASKER
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? :)
Martin Liss

Please post your workbook.
John Darby

ASKER
Marty,

I just referenced the Sub you created for me directly and bingo the button work like a charm! Thank you!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Martin Liss

In your command button's Click event put just Call ColorByIndentLevel If that sub is in a module it should work.
Martin Liss

Once again, you're welcome.