#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Why?

This is the situation: I have a code which when i run in the debugger it
works perfect. I set it to run through all at once and it crashes. Why?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Why?

You probably have the code in a sheet module and when you make unqualified
references, intending to address the activesheet, those unqualified
references instead refer to the sheet containing the code.

--
Regards,
Tom Ogilvy

"Himszy" wrote in message
. uk...
This is the situation: I have a code which when i run in the debugger it
works perfect. I set it to run through all at once and it crashes. Why?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Why?

Hi Tom,
Does that mean he has to copy the code out and put it in "general"?

"Tom Ogilvy" wrote:

You probably have the code in a sheet module and when you make unqualified
references, intending to address the activesheet, those unqualified
references instead refer to the sheet containing the code.

--
Regards,
Tom Ogilvy

"Himszy" wrote in message
. uk...
This is the situation: I have a code which when i run in the debugger it
works perfect. I set it to run through all at once and it crashes. Why?





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Why?

Common problems include:

#1. You're running xl97 and call the code using a control from the control
toolbox toolbar.

If that's the case, change the .takefocusonclick property to false for
that control. If it doesn't have that property, add this line to the
top of your code:

Activecell.activate

(This bug was fixed in xl2k.)

#2. Your code does selects and activates. When you run the code in the VBE,
the correct sheet is active.

When you run it "normally" (you didn't say how), the sheet isn't active.

For the most part, you don't have to select something to work with it.

worksheets("sheet1").select
range("a1").select
activecell.value = "hi"

could be replaced with:
worksheets("sheet1").range("a1").value = "hi"


====
If those don't come close, you'll want to post more details.

How you run the code, where the code is located, what version of excel and the
snippet of code that's causing the trouble.



Himszy wrote:

This is the situation: I have a code which when i run in the debugger it
works perfect. I set it to run through all at once and it crashes. Why?


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Why?

Assuming that is actually his problem, not necessarily. You can certainly
qualify references so Excel doesn't have to guess what they refer to.

--
Regards,
Tom Ogilvy

"David" wrote in message
...
Hi Tom,
Does that mean he has to copy the code out and put it in "general"?

"Tom Ogilvy" wrote:

You probably have the code in a sheet module and when you make

unqualified
references, intending to address the activesheet, those unqualified
references instead refer to the sheet containing the code.

--
Regards,
Tom Ogilvy

"Himszy" wrote in message
. uk...
This is the situation: I have a code which when i run in the debugger

it
works perfect. I set it to run through all at once and it crashes.

Why?







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



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