ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Close user form when button is pressed (https://www.excelbanter.com/excel-programming/364491-close-user-form-when-button-pressed.html)

april27

Close user form when button is pressed
 
Hi! i have a button in a user form. when this button is pressed i want the
user form to close. however, i do not seem to manage this. in the code for
the button antother program is called. but the problem seems to be that the
buttons code is declared private and when i write Close userForm1 the
computer says it is incompatible types. help!!

Norman Jones

Close user form when button is pressed
 
Hi April27,

Look at the Unload statement in VBA help.

The following worked for me:

'=============
Private Sub CommandButton1_Click()
Unload Me
End Sub
'<<=============


---
Regards,
Norman


"april27" wrote in message
...
Hi! i have a button in a user form. when this button is pressed i want the
user form to close. however, i do not seem to manage this. in the code for
the button antother program is called. but the problem seems to be that
the
buttons code is declared private and when i write Close userForm1 the
computer says it is incompatible types. help!!





All times are GMT +1. The time now is 03:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com