If you put this in the userform's code module, pressing the existing X in the corner will bring up the message box you want.

[VBA]Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
MsgBox "Hello world"
End If
End Sub[/VBA]