All - I am using Excel 2007 on a PC and am trying userforms to enter data into a spreadsheet.
I have 4 variables that are specified in a Userform. I am able to write code to do what I want as long as the code is inside the Userform I created.
What I would like to do is to execute a specific Macro placed in a Module so the working parts of this effort would be under Module rather than with the Userform. For the code I want, I can make it more efficient and cleaner by placing it into a Module.
I would have code similar to this below in the Userform to run the Macro I want:
When I write the code in MacroName, I use info from the user that was completed in the UserForm. The variable names below are the names of the Listbox or Textboxes which are used for the variable names of the data:VB:Application.Run "Filename.xlsm'!ModuleName.MacroName"Formatting tags added by mark007
shtname which is a worksheet name
BName which came from a Listbox
Calendar1 which came from a Calender on the Userform
Amount which came from a TextBox
Comments which came from a TextBox
I can code this to work correctly as long as it is inside the Userform code but I cannot use these variables inside the Macro. It appears as if the variables are not recognized.
I did not close the Userform but did Unload the userform to remove it from view of the user.
Do I have to Dim the variables in the Macro ?
Any help or suggestions would be appreciated!