Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default Delete sheet

I am wanting to enter the name of a worksheet in D1, and have a macro that
looks for the worksheet with that name and automatically delete it without
prompts or warnings. Can someone help me out with that code?

Thanks so much
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Delete sheet

right click sheet tabview codeinsert this. If you make a mistake, don't
SAVE the workbook.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$D$1" Then Exit Sub
Application.DisplayAlerts = False
Sheets(Target.Value).Delete
Application.DisplayAlerts = True
End Sub
--
Don Guillett
SalesAid Software

"Tom" wrote in message
...
I am wanting to enter the name of a worksheet in D1, and have a macro that
looks for the worksheet with that name and automatically delete it without
prompts or warnings. Can someone help me out with that code?

Thanks so much


  #3   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default Delete sheet

Thanks Don!

"Don Guillett" wrote:

right click sheet tabview codeinsert this. If you make a mistake, don't
SAVE the workbook.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$D$1" Then Exit Sub
Application.DisplayAlerts = False
Sheets(Target.Value).Delete
Application.DisplayAlerts = True
End Sub
--
Don Guillett
SalesAid Software

"Tom" wrote in message
...
I am wanting to enter the name of a worksheet in D1, and have a macro that
looks for the worksheet with that name and automatically delete it without
prompts or warnings. Can someone help me out with that code?

Thanks so much



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Delete sheet

Same as Dons but with code for errors
Private Sub Worksheet_Change(ByVal Target As Range)
Dim strmsg As String
On Error GoTo SheetError
If Target.Address < "$D$1" Then Exit Sub
Application.DisplayAlerts = False
Sheets(Target.Value).Delete
Application.DisplayAlerts = True
SheetError:
strmsg = "Error # " & Err & " : " & Error(Err)
Select Case Err

Case 9:

MsgBox strmsg & vbCrLf & "Sheet you selected is not a valid sheet"
Exit Sub

Case Else:

MsgBox strmsg
Exit Sub
End Select
End Sub

"Tom" wrote:

I am wanting to enter the name of a worksheet in D1, and have a macro that
looks for the worksheet with that name and automatically delete it without
prompts or warnings. Can someone help me out with that code?

Thanks so much

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
Delete ROW on Sheet#1 corupts data on Sheet#2 Duane Excel Worksheet Functions 4 February 11th 10 07:53 PM
Delete values in sheet 2 that arre found in sheet 1 np Excel Discussion (Misc queries) 1 December 10th 09 07:21 PM
Delete rows from one sheet containing deatils on the second sheet [email protected] New Users to Excel 4 September 6th 07 11:10 AM
delete content of one sheet off another sheet eureka Excel Programming 1 April 4th 06 06:47 AM
delete sheet help 2 RANDY IN NC[_12_] Excel Programming 1 March 22nd 06 09:53 PM


All times are GMT +1. The time now is 06:46 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"