Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default If sheet exists, delete



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 ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default If sheet exists, delete

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
on error goto 0





Darin Kramer wrote:

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 ***


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default If sheet exists, delete



AWESOME!!! Works like a charm!!!

*** Sent via Developersdex http://www.developersdex.com ***
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check for a shape - then change or delete it if it exists Mona-ABE Excel Programming 2 May 30th 07 05:37 PM
Macro in Excel using an Array to Delete File in Directory if it Exists Matt[_40_] Excel Programming 3 February 2nd 07 03:16 AM
If worksheet exists delete cereldine[_43_] Excel Programming 4 July 13th 06 05:26 PM
Sheet name already exists eddie_zoom Excel Discussion (Misc queries) 1 March 11th 05 02:53 PM
How can I know if a sheet exists ? Ben.C Excel Programming 3 December 29th 03 09:36 AM


All times are GMT +1. The time now is 09:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"