Learn Excel 2010 - "Why Won't My Userform Launch?": Podcast #1598

If you like this content, please consider visiting the video on YouTube and subscribe to the MrExcel Channel to show your support!
This video has been published on Sep 10, 2012.
Tony has skills. He has created a great workbook, done his VBA Coding well and has incorporated a Userform into his work to make things simple and smooth... but the Userform won't launch. Clicking the 'Launch' button on the user side produces a 'Compile Error: Expected Function or Variable'. What is causing the error - it's a single, short line of code!? Follow along with Episode #1598 to find out what the issue is and how to correct it quickly.

...This is the video podcast companion to the book, Learn Excel 2007 through Excel 2010 from MrExcel. Download a new two minute video every workday to learn one of the 512 Excel Mysteries Solved! and 35% More Tips than the previous edition of Bill's book!
Power Excel With MrExcel - 2017 Edition

"The Learn Excel from MrExcel Podcast Series"

Visit us: MrExcel.com for all of your Microsoft Excel Needs!
maxresdefault.jpg


Transcript of the video:
MrExcel Podcast is sponsored by Easy-XL.
Learn Excel from MrExcel podcast - Userform Won't Launch Hey! Welcome back to the MrExcel netcast. I'm Bill Jelen.
Today's question is sent in by Tony.
Tony is coming up this VBA learning curve.
He’s doing great things with his reports but he sent me one - he said “I'm banging my head against the wall.
It just seems so simple - why won't this button launch this form?” Alright.
So we click the button and what we have is we have that button assigned to a macro called “SourceForm” and all that does is it does one thing and we have a userform and it does “.Show” on that user form and that generally should work but it is not working today.
I mean how simple can this be?
It's one line of code.
The name of the Userform.Show -- which is the right way to show a form and what's the error message we get?
-- “Expected function or variable” -- what the heck does that mean?
That doesn't tell me anything!
This error should say, “Hey, we're really sorry, but you can't have the macro name and the userform name match.” So, see here - here's the form in the properties.
Instead of userform one, Tony renames it to be SourceForm, which is a great thing to do but then that macro has to be called something else.
It can't be called SourceForm.
So, if I just say “ShowSourceForm” or “MySourceForm” our “GoSourceForm” or even “Bob” or “Tony” -- whatever -- then it will work perfectly.
Now I just changed the name of that macro so we have to come back here, right click, assign macro and assign to ShowSourceForm, click OK.
Alright, that simple change right there.
What a strange problem that Tony ran into there.
It was just coincidental that he happened to have the macro name and the userform name have the exact same thing.
So, there you go.
We'll have to put that error message in the keywords in case anyone else has that, they can see the answer quickly.
Well, hey, I want to thank Tony for sending that question in.
I want to thank you for stopping by.
For more on macros, check out my book - VBA and Macros.
 

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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