View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Hugenstein[_2_] Hugenstein[_2_] is offline
external usenet poster
 
Posts: 1
Default Excel Locks up at end of Sub


I've simplified my code if someone can take a look at it.

If I do the first copy and paste manually (cols E:H), Excel clocks fo
almost a minute, but then functions normally. If I step through th
program, I get no problems until I reach the Exit Sub statement, an
then it freezes. Anyone ever experience anything like this?

Thanks again,
Ryan

=========================================
Sub FactorFormatAfterBB()

' Find range to Autofill

Range("A1").Select
If IsEmpty(Range("A6000")) = False Then
RowOffset = 5999
Range("A6000").Select
Else
If IsEmpty(Range("A3000")) = False Then
RowOffset = 2999
Range("A3000").Select
End If
End If

Do While IsEmpty(ActiveCell) = False
ActiveCell.Offset(R + 1, C).Select
RowOffset = RowOffset + 1
Loop

Range("E2:H" & RowOffset).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
SkipBlanks _
:=True, Transpose:=False

Range("A2").Select
Selection.Sort Key1:=Range("F2"), Order1:=xlAscending
Key2:=Range("A2") _
, Order2:=xlAscending, Header:=xlYes, OrderCustom:=1
MatchCase:=False _
, Orientation:=xlTopToBottom

Range("I1").Select
ActiveCell.FormulaR1C1 = "CAMRA Factor Dt"
Columns("I:I").ColumnWidth = 15.57
Range("j1").Select
ActiveCell.FormulaR1C1 = "N/A Chk"
Range("k1").Select
ActiveCell.FormulaR1C1 = "Past Chk"

Range("C:D").Select
Selection.Delete Shift:=xlToLeft
Range("E8").Select
Range("A1").Select
Selection.AutoFilter

Range("G2").Select
ActiveCell.FormulaR1C1 = "Err!"
Range("H2").Select
ActiveCell.FormulaR1C1 = "DELETE"
Range("I2").Select
ActiveCell.FormulaR1C1 = "Out-of-date"
Range("G2:I2").Select
Selection.AutoFill Destination:=Range("G2:I" & RowOffset)
Range("G2:I" & RowOffset).Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
SkipBlanks _
:=True, Transpose:=False

Application.DisplayAlerts = False
Range("Z1").Select
ActiveCell.FormulaR1C1 = _

"=CONCATENATE(""h:\dataclnp\factors\"",MONTH(TODAY ()),DAY(TODAY()),YEAR(TODAY()),""bb.xls"")"
SaveLoc = Range("Z1")
ActiveWorkbook.SaveAs Filename:=SaveLoc, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Application.DisplayAlerts = True

'--An attempt to end the Sub without the locking

If RowOffset 0 Then Exit Sub

End Su

--
Hugenstei
-----------------------------------------------------------------------
Hugenstein's Profile: http://www.excelforum.com/member.php...fo&userid=2273
View this thread: http://www.excelforum.com/showthread.php?threadid=46721