View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
MrRJ MrRJ is offline
external usenet poster
 
Posts: 109
Default Macro halt - Why?

Patrick,
I did the following and it still created the problem. Not sure what to do.

Private Sub FORMAT()
' This macro formats the file to be used to upload to CCDS

Application.ScreenUpdating = False
Application.CalculateBeforeSave = False

Columns("BA:BA").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Delete shift:=xlToLeft
Range("A1").Select

Columns("P:Q").Select
Selection.Delete shift:=xlToLeft

Columns("D:D").Select 'new change
Selection.Copy
Columns("AO:AO").Select
ActiveSheet.Paste
Range("A1").Select

Range("A1").Select
Columns("I:I").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Columns("A:H").Select
Application.CutCopyMode = False
Selection.Delete shift:=xlToLeft
Columns("A:A").Select
Selection.Insert shift:=xlToRight <==========
Columns("F:F").Select
Selection.Cut
Columns("B:B").Select
Selection.Insert shift:=xlToRight

"Patrick Molloy" wrote:

hmmm I ran the code x1000 in a loop, and it worked fine.

so try
Application.ScreenUpdating=False

at the start of the code and

Application.ScreenUpdating=True

at the and and also switch calculation mode to manual.

"MrRJ" wrote:

Patrick,
I wish that was the answer. Here is part of my code where it stopped at.
Please note, that after I stopped the code and several minutes later, I was
able to insert the column. WHY?

Private Sub FORMAT()
' This macro formats the file to be used to upload to CCDS

Columns("BA:BA").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Delete shift:=xlToLeft
Range("A1").Select

Columns("P:Q").Select
Selection.Delete shift:=xlToLeft

Columns("D:D").Select 'new change
Selection.Copy
Columns("AO:AO").Select
ActiveSheet.Paste
Range("A1").Select

Range("A1").Select
Columns("I:I").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Columns("A:H").Select
Application.CutCopyMode = False
Selection.Delete shift:=xlToLeft

Columns("A:A").Select
Selection.Insert shift:=xlToRight <========here is where it stopped.
Columns("F:F").Select
Selection.Cut
Columns("B:B").Select
Selection.Insert shift:=xlToRight


"Patrick Molloy" wrote:

without seeing the code, its hard to say what the issue is.

As you are inserting a column...it could be that you already have as many
columns as Excel allows?

Patrick

"MrRJ" wrote:

Good morning,

I have a pretty large macro and when I run it, it comes to a halt, with an
error of non blank cells (it stops on a line where I am inserting a column).
I had to stop the code, then I manually tried to insert a column, and it
didn't work.

NOW, after a several minutes later, I tried to insert the column and IT
WORKS! Why is that? It makes no sense to me. Is it working behind the
scenes?

I hear a lot about screenupdating and calculation turning off. Would that
help? I do not have them in my code. If you think I need it, where should I
put them?

Thanks.