Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Procedure fails after updating XP to SP2

My VBA procedure worked yesterday. This morning I upgraded my XP Professional
with Service Pack 2. After the upgrade, when I tried to run the procedure I
got a Microsoft Visual Basic message box with 400 to the right of the red
circle with the X in it and an "OK" button and a "Help" button. Pressing the
"Help" button just produces a blank page. After stepping through the
procedure I found that the problem appears at the second of these lines:

Sheets("Test Matrix").Activate
Range("A3").Activate 'problem line

This is the first change of active sheet. Prior to this point Range worked
fine. Subsequent attempts to activate a range also failed with same error
even when original sheet was re-activated.

Changing the problem line to:

Activesheet.Range("A3").activate

eliminated the problem on that line.

Am I going to have to add the sheet specification to every occurance of
"Range" (there's a boatload)? Or is there another way to deal with this?




--
Glen
  #2   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Procedure fails after updating XP to SP2

Well, I'm not sure of all of the things you are doing with your code, but
generally it is good practice to avoid activating or selecting ranges
whenever something needs to be done.

If you are doing this:
Sheets("Test Matrix").Activate
Range("A3").Activate
Activecell.clearcontents


You could just as easily be doing this:
Sheets("Test Matrix").range("A3").clearcontents

This is a very simple example, but it is just good programming sense to
eliminate unnecessary lines of code.

Sorry if this isn't what you are looking for.
--
JNW


"GlenC" wrote:

My VBA procedure worked yesterday. This morning I upgraded my XP Professional
with Service Pack 2. After the upgrade, when I tried to run the procedure I
got a Microsoft Visual Basic message box with 400 to the right of the red
circle with the X in it and an "OK" button and a "Help" button. Pressing the
"Help" button just produces a blank page. After stepping through the
procedure I found that the problem appears at the second of these lines:

Sheets("Test Matrix").Activate
Range("A3").Activate 'problem line

This is the first change of active sheet. Prior to this point Range worked
fine. Subsequent attempts to activate a range also failed with same error
even when original sheet was re-activated.

Changing the problem line to:

Activesheet.Range("A3").activate

eliminated the problem on that line.

Am I going to have to add the sheet specification to every occurance of
"Range" (there's a boatload)? Or is there another way to deal with this?




--
Glen

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
Stop a Procedure from another procedure Ayo Excel Discussion (Misc queries) 1 October 30th 08 01:42 AM
Updating Chart fails Frank Schuberth Charts and Charting in Excel 1 December 15th 04 01:46 PM
Calling a procedure in a procedure N10 Excel Programming 2 August 18th 04 12:49 AM
updating range value via knowledbase 278973 fails when cell contains formula Ian Ornstein Excel Programming 1 January 29th 04 10:24 AM


All times are GMT +1. The time now is 08:56 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"