View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.misc
Myrna Larson Myrna Larson is offline
external usenet poster
 
Posts: 863
Default On Error Resume Next problem

I hope you have taken note of my comments re the Resume vs Resume Next issue,
and the placement of the On Error Goto 0 statements.

Particularly the latter. You don't want to execute this particular trap for
some error in your code later down.



On Thu, 1 Nov 2007 14:38:03 -0700, Jim May
wrote:

Slick Jim - I will give it a go...
Thanks,
Jim

"Jim Thomlinson" wrote:

Give this a whirl. It avoids jumping around by using a worksheet object...

dim wksSummary as worksheet

on error resume next
set wksSummary = Sheets("Summary")
on error goto 0

if wksSummary is nothing then
sheets.add
activesheet.name = "Summary"
end if
'continue your code here...
--
HTH...

Jim Thomlinson


"Jim May" wrote:

In my code after my DIM statements I have:

On Error GoTo wsAdd
With Sheets("MySummary")
.Activate
.Cells.ClearContents
End With

Let's say MySummary (sheet) does not exist - so macro jumps to:

wsAdd:
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "MySummary"
On Error GoTo 0
Resume Next '<< Creates and Names Sheet MySummary

an returns to the line:

.Activate << Where the Macro Bombs -- What is wrong??