Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a macro that copies a lot sheets, amends them, and deletes the
copied version. Consequently there may be a case for wanting to delete and sheets that end with '(2)'. Is there a handy piece of code that would do that and leave all other sheets alone? Regards, |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This is a modified cut and paste, but you could write a little batch file
like del *2.xls then call with Shell: App_ID = Shell("c:\winnt\system32\cmd.exe NoTwos.bat", 3) "solomon_monkey" wrote in message oups.com... I have a macro that copies a lot sheets, amends them, and deletes the copied version. Consequently there may be a case for wanting to delete and sheets that end with '(2)'. Is there a handy piece of code that would do that and leave all other sheets alone? Regards, |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Untested, but here is some code that looks for a sheet with a ( in it, then
checks if a woirksheet with a name equal to the value before the ( exists. Dim ipos As Long Dim sh As Worksheet Dim sh2 As Worksheet For Each sh In ActiveWorkbook.Worksheets ipos = InStr(1, sh.Name, "(") If ipos 0 Then Set sh2 = Nothing On Error Resume Next Set sh2 = Worksheets(Left(sh.Name, ipos - 2)) On Error GoTo 0 If Not sh2 Is Nothing Then Application.DisplayAlerts = False sh.Delete Application.DisplayAlerts = True End If End If Next sh -- HTH Bob Phillips "solomon_monkey" wrote in message oups.com... I have a macro that copies a lot sheets, amends them, and deletes the copied version. Consequently there may be a case for wanting to delete and sheets that end with '(2)'. Is there a handy piece of code that would do that and leave all other sheets alone? Regards, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Deleting copies of past documents | Excel Discussion (Misc queries) | |||
How do i create upto 50 copies of a spreadsheet within one workboo | Excel Worksheet Functions | |||
Print multiple copies of a spreadsheet on one page | Excel Discussion (Misc queries) | |||
Why when opening a spreadsheet, do two copies appear to open? | Excel Discussion (Misc queries) | |||
How do I make all copies of a spreadsheet file inoperable? | Excel Discussion (Misc queries) |