Need to add something to the end of an existing macro to delete a worksheet

S

Steve

I have a macro that will clean up an Excel version of a Bill of
Materials that gets exported from another software (SQL) from our MRP
system. I would like to add something to the end of the macro to tell
it to delete the "sheet1" worksheet, because the macro I've created
automatically creates a new sheet 2 that I want to replace it. The
message box that automatically appears (for which I want the existing
macro to take care of and not have show up) says "Data may exist in the
sheet(s) selected for deletion. To permanently delete the data press
Delete." Any advice would certainly be appreciated
 
D

Dave Peterson

application.displayalerts = false
on error resume next
activeworkbook.worksheets("sheet1").delete
on error goto 0
application.displayalerts = true

The on error stuff is nice if Sheet1 may not exist.
 
S

Steve

Thanks so much... I wouldn't have come up with this in a million
years, because I'm rather new to this stuff. Worked like a charm,

Best Regards,

Steve
 

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