ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   User Forms (https://www.excelbanter.com/excel-programming/379670-user-forms.html)

Donna C

User Forms
 
On workbook open I have a message box telling the user
what workbook they are in.
I have two questions: When they click "ok" on the message box
I want the user form to open.
The user form is basic with Yes/No boxes.
How do I code for:
When yes is clicked insert new worksheet and run module 1,
when no is clicked simply open the workbook as is for the user to use??
Thanks in advance
Donna C.

Martin Fishlock

User Forms
 
Donna,

In the thisworkbook add the following, or amend if you have it already:

Private Sub Workbook_Open()

If MsgBox(Me.Name, vbOKCancel) = vbOK Then
UserForm1.Show
End If

End Sub


Then on your form code for the two buttons (here called commandbutton1 and
commandbutton2) insert the following code. Note the moudule 1 code may not
work change it to the subroutine name.

Option Explicit

Private Sub CommandButton1_Click()

ThisWorkbook.Worksheets.Add
module1 ' <<<<<< this is the subroutine????
Me.Hide
Unload UserForm1

End Sub

Private Sub CommandButton2_Click()

Me.Hide
Unload UserForm1

End Sub

'------

Save and run the worksheet.
--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"Donna C" wrote:

On workbook open I have a message box telling the user
what workbook they are in.
I have two questions: When they click "ok" on the message box
I want the user form to open.
The user form is basic with Yes/No boxes.
How do I code for:
When yes is clicked insert new worksheet and run module 1,
when no is clicked simply open the workbook as is for the user to use??
Thanks in advance
Donna C.


Simon Lloyd[_907_]

User Forms
 

Donna C;7058947 Wrote:
On workbook open I have a message box telling the user
what workbook they are in.
I have two questions: When they click "ok" on the message box
I want the user form to open.
The user form is basic with Yes/No boxes.
How do I code for:
When yes is clicked insert new worksheet and run module 1,
when no is clicked simply open the workbook as is for the user to
use??
Thanks in advance
Donna C.Donna it's done soemthing like this

Code:
--------------------
If MsgBox("you are in " & ActiveWorkbook.Name & " Would you like to proceed?", vbYesNo, "Workbook Confirmation") = vbYes Then
Sheets.Add
Call '''''''ENTER YOUR MACRO NAME AFTER CALL HERE!
End If
--------------------
Regards,
SImon


--
Simon Lloyd


All times are GMT +1. The time now is 08:11 AM.

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