Forum Discussion

Tommee's avatar
Tommee
Copper Contributor
Jun 21, 2023

Called sub macro disappears after adding ByRef or ByVal variables and exiting out

Hello. I need help with a disappearing called sub macro.

If I create a new sub macro called AccountDesc with nothing in it, & edit it in my macro list it looks like this:

Sub AccountDesc()

‘ Comment: This is called subroutine 

End Sub

I can exit out of it and the name stays in my macro list & I can edit it again adding code and execute it by running it from my macro list. There are no ByRef or ByVal variables in the macro above.

 

If I edit the called macro and insert ByRef or ByVal variables and exit out of it the macro disappears from my macro list and I can't find it or re-edit it so it's lost:

Sub AccountDesc(ByVal Accountnumber As Integer, ByRef Accountinfo As String)

‘ Comment: This is called subroutine #1               

End Sub

After inserting a ByVal and/or a ByRef variable, the macro disappears once I get out of it. Does anyone know how I can have my macro stay in my list and display it's name so I can re-edit it and execute it or run it? Thank you for any help.

  • Tommee 

    A macro is a procedure (sub) without any arguments. The moment you add an argument to a procedure, it is not a macro anymore, so it is no longer listed in the Macros dialog.

    You can still view and edit it in the Visual Basic Editor.

    • Tommee's avatar
      Tommee
      Copper Contributor
      OK. I didn't know that. I'll look for it in the VB Editor. Thank you.

Resources