Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Below is a code that creates a worksheet. How would I get
it to display the error "Duplicate Sheet" and then exit the sub if it detects a sheet with the name of the sheet it is trying to create? Right now if the name of the sheet already exsists when the code trys to create a sheet I get the error "Run time error 1004 Cannot rename a sheet to the same name as another sheet, etc..." Thanx Todd Dim sha As Worksheet Dim shar As Worksheet Set sha = Worksheets(1) 'Set shar = ActiveWorkbook.Worksheets.Add With ActiveWorkbook.Worksheets Set shar = .Add(after:=.Item(.Count)) End With sha.Cells.Copy shar.Cells.PasteSpecial Paste:=xlPasteValues, _ Operation:=xlNone, _ SkipBlanks:=False, _ Transpose:=False shar.Cells.PasteSpecial Paste:=xlPasteFormats, _ Operation:=xlNone, _ SkipBlanks:=False, _ Transpose:=False shar.Name = sha.Range("E2").Value shar.Range("A2").Select ActiveWindow.DisplayZeros = False Worksheets(1).Select |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error handler | Excel Discussion (Misc queries) | |||
Error Handler Question | Excel Discussion (Misc queries) | |||
Error Handler | Excel Discussion (Misc queries) | |||
error handler | Excel Programming | |||
Error handler loop? | Excel Programming |