Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Deleting several rows with given criteria | Excel Discussion (Misc queries) | |||
Deleting rows by specified criteria for duplicates | Excel Discussion (Misc queries) | |||
Deleting the area code on excel spread sheet phone numbers?? | Excel Discussion (Misc queries) | |||
Deleting a sheet via code | Excel Programming | |||
Deleting code in a file with code.. | Excel Programming |