View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
Jim May Jim May is offline
external usenet poster
 
Posts: 477
Default On Error Resume Next problem

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??