View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Getting error unloading Userform??

In a certain workbook, code in the ThisWorkbook module creates a new menu
with one item when the workbook opens. The one item calls a macro in a
general module in the workbook. The macro has one item:
Load UserForm1

The Form_Initialize code gets the name of every sheet in the workbook and
populates a ComboBox control. The form has an "Exit" CommandButton, with
two lines of code:
Set wb = Nothing
Unload Me

When I click the Exit button, the form unloads and disappears, but the code
then errors with 91: Object variable or With variable not set. The VBE
opens with the
Load UserForm1
line in the original macro highlighted in yellow.

How should I fix this?

Ed