Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 72
Default Locating if a Sheet is present in a workbook

Two Part Question:

I am looking for code that will locate if a sheet by a specific name is in
the workbook, and then delete it if it is. What is the easiest way to do
this? (I am not sure if an "IF" statement is the best way to go or not).

Secondly, is there a way to keep the warning pop-up from occurring when
trying to delete said sheet?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Locating if a Sheet is present in a workbook

for each ws in worksheets
application.displayalerts =false
if ws.name="Bad Name" then ws.delete
application.displayalerts=true
next ws

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Shane" wrote in message
...
Two Part Question:

I am looking for code that will locate if a sheet by a specific name is in
the workbook, and then delete it if it is. What is the easiest way to do
this? (I am not sure if an "IF" statement is the best way to go or not).

Secondly, is there a way to keep the warning pop-up from occurring when
trying to delete said sheet?

Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Locating if a Sheet is present in a workbook

on error resume next
application.displayalerts = false
sheets("Sheet1").Delete
application.displayalerts = true
on error goto 0

--
HTH...

Jim Thomlinson


"Shane" wrote:

Two Part Question:

I am looking for code that will locate if a sheet by a specific name is in
the workbook, and then delete it if it is. What is the easiest way to do
this? (I am not sure if an "IF" statement is the best way to go or not).

Secondly, is there a way to keep the warning pop-up from occurring when
trying to delete said sheet?

Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 72
Default Locating if a Sheet is present in a workbook

Thank you so much... works like a charm!!

"Don Guillett" wrote:

for each ws in worksheets
application.displayalerts =false
if ws.name="Bad Name" then ws.delete
application.displayalerts=true
next ws

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Shane" wrote in message
...
Two Part Question:

I am looking for code that will locate if a sheet by a specific name is in
the workbook, and then delete it if it is. What is the easiest way to do
this? (I am not sure if an "IF" statement is the best way to go or not).

Secondly, is there a way to keep the warning pop-up from occurring when
trying to delete said sheet?

Thanks!


.

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
Locating a Worksheet from another Workbook Walter Excel Worksheet Functions 12 March 13th 09 07:59 PM
locating cell info from one sheet omss Excel Worksheet Functions 1 December 27th 07 10:05 PM
List all sheets present in Workbook Jeff Excel Worksheet Functions 6 November 9th 06 09:03 PM
How can I count number of sheets present in a workbook? Imran Excel Discussion (Misc queries) 1 October 6th 06 11:06 AM
LOCATING A CHART SAVED IN A WORKBOOK FLKULCHAR Excel Discussion (Misc queries) 0 June 24th 05 05:26 AM


All times are GMT +1. The time now is 11:50 PM.

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

About Us

"It's about Microsoft Excel"