Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
VanS
 
Posts: n/a
Default Error on worksheet delete


Hello,
When running the code below-by clicking a command button whose code deletes
all but the first 3 worksheets in the workbook-I keep getting an error
message"
"This program has performed an illegal operation and will be shut down". So
I ran it in debug to trace the point of error. It occurs after the sheet is
deleted, and the code goes to the worksheet_deactivate routine, performs its
duties and at the point it tries to return to the command button/For ndx code
it bonkers out.
The code works fine under Office XP & 2003 with Win XP, but I am testing
with a Win98 Office 97 testbed under MS Virtual PC-the latter is where the
problem lies. I have checked that the library files are correct for Office
97. Not sure if significant, but the global variable strWorksht under
worksheet_deactivate is populated with the name of the deleted worksheet for
the one working, but empty for the one not working.
Any ideas what could be the problem?
Thanks, God bless
Van

Command button click
For ndx = Workbooks("Quotes.xls").Worksheets.Count To 4 Step -1
' Debug.Print Workbooks("Quotes").Worksheets(ndx).Name
' Debug.Print ndx
' Workbooks("Quotes").Worksheets(ndx).Activate

Workbooks("Quotes.xls").Worksheets(ndx).Delete

Next ndx
' for worksheet being deleted
Private Sub Worksheet_Deactivate()
Dim intYN As Integer
Dim intEndRw As Integer
Dim strFileNum As String
Dim intFileNum As Integer
'Dim strPath As String

booPerform = False
If strWorksht = "" Then Exit Sub
If booQtCreate Then Exit Sub
Application.OnKey "{TAB}" 'fix 08/06/99
Exit Sub
' **************************
If Worksheets(strWorksht).ProtectContents = False Then
Worksheets(strWorksht).Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True ', UserInterface:=True
End If

End Sub




Reply
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
copyright and worksheet protection dow Excel Discussion (Misc queries) 2 January 3rd 05 03:07 PM
Executing macro for all worksheet from a different worksheet Biti New Users to Excel 3 December 8th 04 10:05 AM
Reference Data in Moved Worksheet tommcbrny Setting up and Configuration of Excel 1 December 1st 04 06:49 PM
Linking items GREATER THAN O on another worksheet in the same Work Eddie Shapiro Excel Discussion (Misc queries) 4 December 1st 04 02:55 PM
Worksheet name and Backward compatibility Rich Excel Discussion (Misc queries) 3 November 30th 04 06:10 PM


All times are GMT +1. The time now is 07:16 PM.

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

About Us

"It's about Microsoft Excel"