Running macro with optional parameters

dhregan

New Member
Joined
Mar 30, 2010
Messages
37
Hello -

I have a macro with the following signature: Sub Create_Table (Optional ByVal WCP_Special As Boolean = True). While this macro is typically called from another macro most of the time, there are some occasions when I want to call it as a standalone. However, I am unable to do that through the VBA menu. Can this be done?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Not that I'm aware of.
 
Upvote 0
Hello -

I have a macro with the following signature: Sub Create_Table (Optional ByVal WCP_Special As Boolean = True). While this macro is typically called from another macro most of the time, there are some occasions when I want to call it as a standalone. However, I am unable to do that through the VBA menu. Can this be done?
Technically, that is not a macro, rather, it is just a plain subroutine... macros always have no arguments.

When you say "VBA menu", so you mean the dialog box that appears when you press ALT+F8 which allows you to pick the macro you want to run? If so, then the only way I can think to do what you ask is to create a macro that calls your subroutine and call it when you want to not specify the argument. Something like this...
Code:
Sub Create_Table_True()
  Call Create_Table()
End Sub
 
Upvote 0
Thanks Rick. I was hoping to avoid that approach, but it seems to be the most common way to address it.
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,314
Members
449,081
Latest member
tanurai

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