On Tuesday, April 9, 2013 2:22:42 AM UTC-7, Claus Busch wrote:
Hi Howard,
Am Mon, 8 Apr 2013 23:54:20 -0700 (PDT) schrieb Howard:
For Each c In Selection
Application.DisplayAlerts = False
Sheets(c.Value).Delete
Selection.ClearContents
Application.DisplayAlerts = True
Next
because you ClearContents into the For-Next-Statement.
So there is no other name left.
In Code below the last line will sort that you don't have empty rows.
Try:
Sub DeleteSheets()
Dim rngC As Range
Application.DisplayAlerts = False
For Each rngC In Selection
Sheets(rngC.Text).Delete
Next
Selection.Resize(, 5).ClearContents
Range("C8:G32").Sort key1:=[C9], order1:=xlAscending, Header:=xlYes
Application.DisplayAlerts = True
End Sub
Regards
Claus Busch
I tried the code in the sheet
vb editor and it deleted the sheets but the names and formulas to the right remain intact.
Produces a error 400
I tried the code in a module and the sheet are deleted and the names and formula remain intact.
errors out on this line yellow hi-light
Selection.Resize(, 5).ClearContents
Howard