Page 221 - Excel Data Analysis
P. 221

11 537547 Ch10.qxd  3/4/03  12:03 PM  Page 207






                                                                                           FORM CONTROLS 10









                                  You can use the Unload statement to remove a  You can hide a UserForm so that it is no longer
                                  UserForm from memory. When you call the    visible when a macro calls it. You do so using the
                                  statement, all controls on the UserForm reset to  Hide method, which still enables you to access the
                                  their default values. Therefore, you cannot access  form from your procedure. To hide a form, use the
                                  the options a user specifies after the UserForm  statement:
                                  unloads from memory. To ensure that you can
                                  access the necessary values, you can either store  Example:
                                  the values in global variables or hide the  UserForm1.Hide
                                  UserForm until your procedure terminates. You  After you hide a form, Excel may appear to freeze as
                                  unload a UserForm by typing the Unload     your code continues to access the UserForm. This
                                  statement followed by the name of the UserForm  condition clears as soon as the code that accesses
                                  to unload as follows:                      the UserForm finishes processing.
                                 Example:
                                  Unload UserForm1



































                     ˇ Type UserForm1.Show                              Á Switch to Excel and run   ■ The specified UserForm
                     vbModal, replacing UserForm1                       the macro.                appears as a custom dialog
                     with the name of the form and                                                box.
                     vbModal with vbModelss if
                     you want to make the dialog
                     box modeless.
                                                                                                                     207
   216   217   218   219   220   221   222   223   224   225   226