If sheet exists, delete

D

Darin Kramer

Hi there,

I have an array of sheets, and which ever ones are visible I would like
it to be deleted, if not do nothing..

So for eg if Master_D and Master are visible then delete them (curretnly
VB is getting stuck cause its trying to delete Master, and it isnt
visible...

Sheets(Array "Master_D", "Master_A", "Master").Activate
ActiveWindow.SelectedSheets.Delete

Thanks!!!

D

*** Sent via Developersdex http://www.developersdex.com ***
 
D

Dave Peterson

dim myNames as variant
dim iCtr as long
mynames = Array("Master_D", "Master_A", "Master")

on error resume next 'in case it doesn't exist
application.displayalerts = false
for ictr = lbound(mynames) to ubound(mynames)
sheets(mynames(ictr)).delete
next ictr
application.displayalerts = true
 

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