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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022
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.
 

LAS

Board Regular
Joined
Oct 29, 2002
Messages
215
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?
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022
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.
 

just_jon

Legend
Joined
Sep 3, 2002
Messages
10,473

ADVERTISEMENT

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.
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022
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).
 

just_jon

Legend
Joined
Sep 3, 2002
Messages
10,473

ADVERTISEMENT

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.
 

Cbrine

Well-known Member
Joined
Dec 2, 2003
Messages
3,196
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.
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022
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.
 

LAS

Board Regular
Joined
Oct 29, 2002
Messages
215
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,100
Messages
5,768,095
Members
425,452
Latest member
htay44

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
Top