Why is my code Pausing???

LAS

Board Regular
Joined
Oct 29, 2002
Messages
215
HI

I have code written for two programs.
Identical code except for a > sign to filter out a date in the one and < sign in the other.

When I press ctrl+break to go to debug mode
the program stalls at
cells(1,1)="temp" in
.
.
activesheet.paste
cells(1,1)="temp"
.
.

after clicking continue it runs fine but it just seems to stall there.
This is not part of a loop.
any ideas?


thanx
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
No clue as to why this would hang. But have you tried alternate code to see if it still hangs? i.e.

[A1] = "temp"

or

Range("A1") = "temp"

(assuming Cells(1,1) points to [A1].)

You might also try sticking an Application.CutCopyMode = False after the Paste command to clear the clipboard if you no longer need the clipboard's contents.
 
Upvote 0
I tried that changing
cells(1,1) to range("A1") and adding
application.cutcopymode=false
it still doesnt work.


What seems to be happening is it copies the selected range
and before the paste the the CPU usage is on minimal usage when it comes to the paste the CPU usage goes up to 100%.
and the selected range to be copied isnt that big +- 1500 lines.

and the strange part is it works fine on the other program.

any ideas?
 
Upvote 0
Hmmm. You might try sticking an Application.Calculation = xlCalculationManual before the part that hangs and then reset the calc mode manually after the macro is done. If that works then test again putting Application.Calculation = xlCalculationAutomatic in at the end of the macro.
 
Upvote 0
If it halts at the same time every time, my guess is you've set a breakpoint --
You set a breakpoint to suspend execution at a specific statement in a procedure; for example, where you suspect problems may exist. You clear breakpoints when you no longer need them to stop execution.

To set a breakpoint

Position the insertion point anywhere in a line of the procedure where you want execution to halt.


On the Debug menu, click Toggle Breakpoint (F9), click next to the statement in the Margin Indicator Bar (if visible), or use the toolbar shortcut: .
The breakpoint is added and the line is set to the breakpoint color defined on the Editor Format tab in the Options dialog box.

If you set a breakpoint on a line that contains several statements separated by colons :)), the break always occurs at the first statement on the line.

To clear a breakpoint

Position the insertion point anywhere on a line of the procedure containing the breakpoint.


From the Debug menu, choose Toggle Breakpoint (F9), or click next to the statement in the Margin Indicator Bar (if visible.)


The breakpoint is cleared and highlighting is removed.
To clear all breakpoints in the application

From the Debug menu, choose Clear All Breakpoints (CTRL+SHIFT+F9).
Note Breakpoints set in code are not saved when you save your code.
 
Upvote 0
Hi Jon. I am going to be really embarrassed for missing the obvious if this is the case. But we're on the second day and assuming LAS went home overnight (and turned off the computer), breakpoints would get cleared upon closing and re-opening a file (or at least they do for me).
 
Upvote 0
Yeay, I thought that too but if I had a nickle for every time I hit F9 while trying to step thru some code... well, I'd be a rich fellow! A straight assisnment of a text value to a cell shouldn't do anything... unless there was an event macro tied to that cell, perhaps.
 
Upvote 0
Yeah,
On occasion I have had break points, that I had removed, still act like they were there. This has never occurred after closing and opening excel again though.
 
Upvote 0
Lawrence,

Jon raises an excellent question. Do you have anything in a Worksheet_Change() event handler? An infinite loop in this area would drive your CPU usage up like you describe.
 
Upvote 0
I am embarrassed :pray:

I was unaware that one of my colleges added a complex vlookup formula to the workbook data I am copying from which when pasted caused links to an external document. :oops:

Thanks for all your suggestions and ideas.
 
Upvote 0

Forum statistics

Threads
1,214,666
Messages
6,120,806
Members
448,990
Latest member
rohitsomani

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top