RTrim removes trailing spaces from the right side of a string
The MsgBox is there to ensure that the user has made a selection in that dropdown before clicking the CommandButton1. The user won't see the MsgBox unless they forgot to make a selection before running the macro. This is a validation step that would ensure you have correct data.
Graham gave you two separate macros. The Unload Me is NOT in the initialise macro. It is in the CommandButton1 macro that would be run by the user to transfer the option into the document variables and then close the userform. You could easily remove that line from the CommandButton1 code without changing the other functionality but Graham happened to include it as he probably assumed you would be finished with the userform if you were wanting to pass the values to the document.
The point of the two separate macros is there are two stages for userform functionality
1. Initialise sets the default values on the userform when the user first sees it.
The user can then interact with the userform and change values or click on things - this may or may not involve macros running.
2. The CommandButton action should then:
2.a Validate the user made changes to the form that are acceptable
2.b Transfer the user's provided information to whereever it needs to go
2.c Close the userform
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
|