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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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,215,584
Messages
6,125,670
Members
449,248
Latest member
wayneho98

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