0

I am new to Excel macro, I try to write a testing macro named Test without parameter, and then in Excel workbook, press the macro button, the testing macro is shown as follow:

enter image description here

enter image description here

but if I add a parameter to the macro Test as

Public Sub Test(var1 As String)

then when I return to the workbook, press the macro button, the Test macro is not shown, why? Is macro cannot with parameter?

enter image description here

enter image description here

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
user1169587
  • 1,104
  • 2
  • 17
  • 34

1 Answers1

1

The macro is not shown because you have forced a parameter to be passed as part of the procedure, thus rendering the procedure unavailable to be run on a stand-alone basis.

Scott Holtzman
  • 27,099
  • 5
  • 37
  • 72
  • In fact I think it should still be shown, just when user press run button, force user to assign input parameter value – user1169587 Jun 26 '19 at 14:19
  • 1
    @user1169587 then remove the parameter from the procedure (so it is shown), and make the procedure ask the user for input unsing the [Application.InputBox method](https://learn.microsoft.com/en-us/office/vba/api/excel.application.inputbox). – Pᴇʜ Jun 26 '19 at 14:23