View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Terry von Gease Terry von Gease is offline
external usenet poster
 
Posts: 38
Default difference between 2000 and 2002?

Under Excel 2002 the following works just fine:

Worksheets.Add
With ActiveSheet
.Name = "scratch"
.Visible = False
End With

A new sheet named "scratch" is created and hidden. However, under Excel 2000
no new sheet is created yet no error occurs. In fact no sheet by any name
whatsoever is added under 2000. The thing doesn't complain but it doesn't
add a sheet either.

Here is the entire subroutine just in case something is wrong with the
events leading up to the malfeasant section...

Sub new_scratch()

Set sht = ActiveSheet
Application.DisplayAlerts = False
On Error Resume Next
Sheets("scratch").Delete
On Error GoTo 0
Application.DisplayAlerts = True
Worksheets.Add
With ActiveSheet
.Name = "scratch"
.Visible = False
End With
sht.Activate

End Sub

The part that deletes any existing "scratch" sheet works just fine in 2000
or 2002. If a "scratch" sheet exists it is indeed deleted. It's just that
with 2000 no new sheet ever gets added. This situation is discovered a bit
later when another snippet of code tries the following:

'hider = xlVeryHidden
hider = False
Sheets("data").Visible = hider
Sheets("scratch").Visible = hider
Sheets("formats").Visible = hider

The 'Sheets("scratch").Visible = hider' line dies with the predictable
"Run-time error 9: Subscript out of range" error since there is no
Sheets("scratch")

I really need to fix this. What I really don't need is a "Doc it hurts when
I do this", "Then don't do that" answer. This, right here, HAS to work.

Anyone have any insight here?

--
Terry

"I said I never had much use for one,
I never said I didn't know how to use one."
M. Quigley