Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Deleting a sheet via code-- different criteria

Hi Again...

I've thought of a better way to remove unwanted worksheets from my
workbook....

I need to run code that will delete all worksheets in my activeworkbook that
have "Delete" in cell A3 of the worksheet.
Cell A3 has a formula in it of each worksheet that determines if the sheet
needs to be deleted or not... if it needs to be deleted.. then, the formula
returns "delete"...otherwise..it's blank "".


I think this will work better than my previous post......


I'm not sure how to do this ... so any help is greatly appreciated..

Thanks in advance,
Kimberly


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleting a sheet via code-- different criteria

sub test
dim sht as sheet
for each sht in activeworkbook
if sht.range("A3")="delete" then
sht.delete
end if
next
end sub


"KimberlyC" wrote in message
...
Hi Again...

I've thought of a better way to remove unwanted worksheets from my
workbook....

I need to run code that will delete all worksheets in my activeworkbook

that
have "Delete" in cell A3 of the worksheet.
Cell A3 has a formula in it of each worksheet that determines if the sheet
needs to be deleted or not... if it needs to be deleted.. then, the

formula
returns "delete"...otherwise..it's blank "".


I think this will work better than my previous post......


I'm not sure how to do this ... so any help is greatly appreciated..

Thanks in advance,
Kimberly




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Deleting a sheet via code-- different criteria

Don't forget to set

Application.DisplayALerts = False

to avoid the warning, and reset at the end.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Kim" wrote in message
...
sub test
dim sht as sheet
for each sht in activeworkbook
if sht.range("A3")="delete" then
sht.delete
end if
next
end sub


"KimberlyC" wrote in message
...
Hi Again...

I've thought of a better way to remove unwanted worksheets from my
workbook....

I need to run code that will delete all worksheets in my activeworkbook

that
have "Delete" in cell A3 of the worksheet.
Cell A3 has a formula in it of each worksheet that determines if the

sheet
needs to be deleted or not... if it needs to be deleted.. then, the

formula
returns "delete"...otherwise..it's blank "".


I think this will work better than my previous post......


I'm not sure how to do this ... so any help is greatly appreciated..

Thanks in advance,
Kimberly






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleting a sheet via code-- different criteria


Kim,
I tried your code and it would stop at the second and third line.
I had to change them to make it work. After i changed them it worked
fine.
My question is:
Why and what is the difference, between the two statements?
What is the difference between Sheet and Worksheet?

The red is what i changed them to.
sub test
'dim sht as sheet
Dim sht As Worksheet
'for each sht in activeworkbook
For Each sht In ActiveWorkbook.Worksheets
if sht.range("A3")="delete" then
sht.delete
end if
next

Thx
Dave
Kim Wrote:
sub test
dim sht as sheet
for each sht in activeworkbook
if sht.range("A3")="delete" then
sht.delete
end if
next
end sub


"KimberlyC" wrote in message
...
Hi Again...

I've thought of a better way to remove unwanted worksheets from my
workbook....

I need to run code that will delete all worksheets in my

activeworkbook
that
have "Delete" in cell A3 of the worksheet.
Cell A3 has a formula in it of each worksheet that determines if the

sheet
needs to be deleted or not... if it needs to be deleted.. then, the

formula
returns "delete"...otherwise..it's blank "".


I think this will work better than my previous post......


I'm not sure how to do this ... so any help is greatly appreciated..

Thanks in advance,
Kimberly




--
Piranha
------------------------------------------------------------------------
Piranha's Profile: http://www.excelforum.com/member.php...o&userid=20435
View this thread: http://www.excelforum.com/showthread...hreadid=386308

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Deleting a sheet via code-- different criteria

I got caught by this the other day -

Sheets includes worksheets and chart sheets

Worksheets doesn't include chart sheets.
--
steveB

Remove "AYN" from email to respond
"Piranha" wrote in
message ...

Kim,
I tried your code and it would stop at the second and third line.
I had to change them to make it work. After i changed them it worked
fine.
My question is:
Why and what is the difference, between the two statements?
What is the difference between Sheet and Worksheet?

The red is what i changed them to.
sub test
'dim sht as sheet
Dim sht As Worksheet
'for each sht in activeworkbook
For Each sht In ActiveWorkbook.Worksheets
if sht.range("A3")="delete" then
sht.delete
end if
next

Thx
Dave
Kim Wrote:
sub test
dim sht as sheet
for each sht in activeworkbook
if sht.range("A3")="delete" then
sht.delete
end if
next
end sub


"KimberlyC" wrote in message
...
Hi Again...

I've thought of a better way to remove unwanted worksheets from my
workbook....

I need to run code that will delete all worksheets in my

activeworkbook
that
have "Delete" in cell A3 of the worksheet.
Cell A3 has a formula in it of each worksheet that determines if the

sheet
needs to be deleted or not... if it needs to be deleted.. then, the

formula
returns "delete"...otherwise..it's blank "".


I think this will work better than my previous post......


I'm not sure how to do this ... so any help is greatly appreciated..

Thanks in advance,
Kimberly




--
Piranha
------------------------------------------------------------------------
Piranha's Profile:
http://www.excelforum.com/member.php...o&userid=20435
View this thread: http://www.excelforum.com/showthread...hreadid=386308



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
Deleting several rows with given criteria Rechie Excel Discussion (Misc queries) 7 October 20th 09 01:38 PM
Deleting rows by specified criteria for duplicates Tasha Excel Discussion (Misc queries) 4 September 9th 08 10:48 AM
Deleting the area code on excel spread sheet phone numbers?? Ben Excel Discussion (Misc queries) 4 October 3rd 07 01:34 PM
Deleting a sheet via code KimberlyC Excel Programming 4 July 12th 05 01:20 AM
Deleting code in a file with code.. KimberlyC Excel Programming 3 March 4th 04 09:24 PM


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

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"