Code execution has been interupted Problem

guybrown

Board Regular
Joined
Jul 2, 2008
Messages
100
hi all!

It sometimes highlights End With and sometimes highlights Range("C2:C10001").Select

Any idea what the problem might be?

Guy xp prof xl 2007


Sub Text_on_XY()

'AutoFill
Range("C2:C2").AutoFill Destination:=Range("C2:C" & Cells(Rows.Count, "B").End(xlUp).Row)
'Paste formula result as value
Range("C2:C10001").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

'Sort 1 2 3
Range("C2:D10001").Select
ActiveWorkbook.Worksheets("Text on XY").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Text on XY").Sort.SortFields.Add Key:=Range( _
"D2:D8"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Text on XY").Sort
.SetRange Range("C2:D10001")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
I've not seen an explanation for that, but maybe putting:

Application.EnableCancelKey = xlDisabled

at the beginning of your code will fix the problem.
 

guybrown

Board Regular
Joined
Jul 2, 2008
Messages
100

ADVERTISEMENT

well i wasn't pressing escape but it seems to have fixed it... cheers
 

Stray__CAt

New Member
Joined
May 12, 2009
Messages
31
It sounds like you hit the Esc key (or there was a hit pending) while your code was running.

In rare cases, anyway, VBA keeps stopping where you placed a breakpoint, even if the breakpoint has been subsequently deleted. In that case the only solution is to copy the module code, drop the module, insert another and copy the code back. It's a bug, no use to say.
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
In rare cases, anyway, VBA keeps stopping where you placed a breakpoint, even if the breakpoint has been subsequently deleted. In that case the only solution is to copy the module code, drop the module, insert another and copy the code back. It's a bug, no use to say.

That sounds like a plausible explanation, although I don't remember having set and removed a break point when it's happened to me. It's certainly some sort of bug.
 

Colin Legg

MrExcel MVP
Joined
Feb 28, 2008
Messages
3,497
Office Version
  1. 365
  2. 2016
Platform
  1. Windows

Forum statistics

Threads
1,136,341
Messages
5,675,206
Members
419,553
Latest member
hanahass

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