macro trouble for excel

tex1014

New Member
Joined
May 5, 2015
Messages
2
I am trying to create a macro with parameters:

Sub FormatColumns(Optional fUnderscore As Boolean = False)

...

End Sub

Once the argument is added, the macro name disappears from the macro selection screen once I hit alt + F8. When I take the argument out, the macro is there. I don't want to create a duplicate macro when I could set the Boolean variable to optional.

Thanks,
Programmer Novice
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You could have a 2nd macro that appears in the macro list. That 2nd macro simply calls FormatColumns

Code:
[COLOR=darkblue]Sub[/COLOR] FormatColumns_Default()
    FormatColumns
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]

[COLOR=darkblue]Sub[/COLOR] FormatColumns([COLOR=darkblue]Optional[/COLOR] fUnderscore [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Boolean[/COLOR] = [COLOR=darkblue]False[/COLOR])

[COLOR=green]'...[/COLOR]

[COLOR=darkblue]End[/COLOR] Sub
 
Last edited:
Upvote 0
AlphaFrog,

Thanks, but it is the first macro I am creating. There are no other macros on my computer.

Novice Programmer
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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