userform delete sheet

D

dok112

When using my userform, I want it to delete a page from the book in th
end. I have the code for deleting it, but it pops up that dialogue bo
asking me to delete it again. How do I write into the macro to confir
the deletion?

Private Sub CommandButton1_Click()
MsgBox "Your Submission is being recorded and printed"
MsgBox "Please make sure you place a copy in the Representativ
Perfect Folder"
Dim ctrl As Control
Dim chkbx As MSForms.CheckBox
For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
Set chkbx = ctrl
If chkbx Then
Worksheets(chkbx.Caption).PrintOut
End If
End If
Next
SHEETS(\"T2S\").SELECT
ACTIVEWINDOW.SELECTEDSHEETS.DELETE

newFolder$ = "C:\Documents and Settings\Administrator\Desktop\"
TextBox1.Text
MkDir newFolder$
NewFile$ = newFolder$ & "\" & TextBox2.Text & ".xls"
ThisWorkbook.SaveAs NewFile$
Unload Me
End Su
 
T

Tom Ogilvy

application.DisplayAlerts = False
SHEETS(\"T2S\").SELECT
ACTIVEWINDOW.SELECTEDSHEETS.DELETE
Application.DisplayAlerts = True
 
D

dok112

Ok, can I use the same concept to delete a sheet if it is unchecked.
Basically, the form is going to print out all the sheets that ar
checked, and I need it to delete the unchecked sheets before it save
the file to one of my drives.

Dim ctrl As Control
Dim chkbx As MSForms.CheckBox
For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
Set chkbx = ctrl
If chkbx Then
Worksheets(chkbx.Caption).PrintOut
End If
End If
Nex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top