Hi,

Is there a way to disable the close icon on a userform? (The x in the top right hand corner)

Basically I need the sub to exit if the userform is canceled rather than if Ok is selected (and hence data has been entered). I have this working fine by setting a variable (IERROR ) to true if [cancel] is selected. however if the user were to close the userform wit the 'x' then this value would not be assigned and the program would continue to try and run without the vital data.

Ideally I would like to be able to assign the [Cancel] code to the 'x' as well, but failing that, dissabling it will also solve the problem. As a third option is there a way to tell whether the userform was exited this way rather than via a command button?