ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why? (https://www.excelbanter.com/excel-programming/319818-why.html)

Himszy

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?



Tom Ogilvy

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?





David

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?






Dave Peterson[_5_]

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

Tom Ogilvy

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?









All times are GMT +1. The time now is 06:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com