PDA

View Full Version : Delete Selected Sheet



tjtsantos
10-03-2008, 08:33 AM
Hi Experts,

Thank you for all your help. I just want to ask if Excel has a functionality selecting what sheets to be deleted. I have a workbook that has 50++ sheets. I would like to create a function (probably a customized "Remove Sheet" button). Whenever this function is called. It will popup list of all the sheets which you can select individually (probably by ticking a checkbox) and then a delete confirmation button.

You guys have been very helpful. Thank you in advance.

Regards,

Tony

jfournier
10-03-2008, 10:10 AM
I put together a simple demo of how to do this (see attached). Basically you just create a user form with a listbox (with multi select enabled). When the form loads you add every worksheet name to the listbox. Then you select all the sheets you want to delete, and hit a button that runs through your listbox's items and sees which are selected, deleting each.

tjtsantos
10-03-2008, 01:35 PM
Hi jfournier,

Thank you very much. I was able to work on the user form and I was able to generate the list when I ran the codes. However, I would like to run it from a command button (ex: Remove Sheet). Once I clicked on this button, the user form will popup giving me an option to delete. How can I work around this.

As I see from your attachment that I need to go to Visual Basic and run the scripts from there, then the user form will popup. How can I link the script from a command button ("Remove Sheet")

Regards,

Tony

jfournier
10-03-2008, 01:42 PM
your script just needs to say "frmDeleteSheets.Show 0"

replace frmDeleteSheets with whatever I named the form. I don't remember at the moment.

vzachin
10-03-2008, 06:58 PM
check this out from Tstav:
http://vbaexpress.com/kb/getarticle.php?kb_id=998


zach

tjtsantos
10-04-2008, 09:47 PM
Thanks a lot!!!