Search code examples
excelmodulecallvba

Calling a module within a sub


I have reviewed other questions related to calling a module within a sub but the solutions do not seem to be applicable to my case. I am trying to run code within a module when there is a change within a userform textbox which I have named filepath1.

Below is a copy of the code I am trying to run. Each time I get a compile error "Expected variable or procedure, not module." To confirm the name of my module is not the same as any other name in the sub or userform. Any advice is appreciated!

Private Sub Filepath1_Change()
   Call ChangeFilepath
End Sub

Solution

  • For the most part, the module can be safely ignored. You're not trying to run a module, you're trying to run a subroutine that's stored in a module, and as long as it's not set to private you shouldn't need to specify the module name.

    If you had a macro called "ChangePath" in a module called "UpdateFilepath", your call would be Call ChangePath.