cocopops2001
Board Regular
- Joined
- Apr 18, 2011
- Messages
- 112
i am having a slight problem with my userform. the form allows the user to either select an existing workbook or create a new work book into which a sheet is to be copied.
its probably something really simple but i want the form to run a macro when a button is pushed but when the X button on the form is clicked the 'sheetcopy' macro still runs but i dont want it to. ie it adds sheets to my master workbook instead of a new one, obviously because the new one is not created. i know i need a line to tell it to abort the 'sheetcopy' but not sure what. Im getting on quite well at this but not used to the VBA commands yet.
i did get this button code from a forum and modified it to suit my needs so maybe deleted/added something i shouldnt have. any help would be great, Thanks
also if you think there is a better way to do this then i open to suggestions
its probably something really simple but i want the form to run a macro when a button is pushed but when the X button on the form is clicked the 'sheetcopy' macro still runs but i dont want it to. ie it adds sheets to my master workbook instead of a new one, obviously because the new one is not created. i know i need a line to tell it to abort the 'sheetcopy' but not sure what. Im getting on quite well at this but not used to the VBA commands yet.
i did get this button code from a forum and modified it to suit my needs so maybe deleted/added something i shouldnt have. any help would be great, Thanks
also if you think there is a better way to do this then i open to suggestions
Code:
Private Sub CommandButton2_Click()
Workbooks.Add
sheetcopy
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub CommandButton1_Click()
OpenCalc
sheetcopy
End Sub
Private Sub CommonDialog1_AfterUpdate()
End Sub
Private Sub CommonDialog1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
End Sub
Private Sub CommonDialog1_Enter()
End Sub
Private Sub CommonDialog1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
End Sub