+ Reply to Thread
Results 1 to 2 of 2

Excel Locks up at end of Sub

  1. #1
    Registered User
    Join Date
    04-27-2005
    Posts
    2

    Excel Locks up at end of Sub

    My Macro worked fine, then one day it started locking up excel right before the end of the sub. I have to End task out. The macro saves the file with a new filename at the beginning. If I open that file and try to rerun the macro after the lock up, it works all the way through. I'm thinking it's a memory overflow thing or something with the new file not existing. I don't know.

    The code is below. The macros reside in a seperate workbook than the book being modified, the macros are initiated through the menu bar.

    Thanks for looking, Ryan
    ==========================================================
    Last edited by Hugenstein; 09-16-2005 at 09:47 AM.

  2. #2
    Registered User
    Join Date
    04-27-2005
    Posts
    2

    Copy and Paste causing the problem

    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 for almost a minute, but then functions normally. If I step through the program, I get no problems until I reach the Exit Sub statement, and 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 Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1