LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default On Error GoTo .... error

I have the following code which is supposed to enter a new worksheet,
rename it "Working Template" and do other stuff. There is an error
check that is supposed to flag the error that occurs if a "Working
Template" sheet already exists - then delete the current (newly added)
sheet and the "Working Template", then go back to the beginning. For
some reason, though, it's just not working at all. I wrote the code
on another computer and had no problems, but on this machine it
refuses to catch it. I could rewrite it to circumvent the problem,
but it is happening elsewhere too, so i would like to get a better
understanding of why.

Any advice or recommendations would be greatly appreciated.

Function ()
beginning:
Sheets.Add After:=Sheets(6)
On Error GoTo error_occured
Sheets(7).Name = "Working Template"
Sheets(6).Cells.Copy
Sheets(7).Select
With Selection
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
End With
Cells.UnMerge
Exit Function

error_occured:
Application.DisplayAlerts = False
ActiveSheet.Delete
Sheets("Working Template").Delete
Application.DisplayAlerts = True
Resume beginning
End Function

Thanks,
Thedude
 
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
On Error Goto ... Error witek Excel Programming 0 September 18th 06 04:50 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
ON Error goto fails on 2nd error BAC Excel Programming 4 March 15th 05 09:03 PM
On Error GoTo StanJ[_2_] Excel Programming 1 July 31st 04 06:15 PM
How can I still go to the error-code after a On Error Goto? Michel[_3_] Excel Programming 2 May 4th 04 04:21 AM


All times are GMT +1. The time now is 08:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"