+ Reply to Thread
Results 1 to 3 of 3

Run Time error 7 - out of memory

Hybrid View

sfw1973 Run Time error 7 - out of... 01-24-2013, 05:27 PM
scott.s.fower Re: Run Time error 7 - out of... 01-24-2013, 07:30 PM
sfw1973 Re: Run Time error 7 - out of... 01-25-2013, 11:55 AM
  1. #1
    Registered User
    Join Date
    01-24-2013
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    2

    Run Time error 7 - out of memory

    Please help!
    I keep getting this error and it is driving me mad.
    Here is the code i am using

    Public Sub CommandButton1_Click()
    Dim wbRead As Workbook

    Application.ScreenUpdating = False

    Set wbRead = Workbooks.Open("G:\New Desktop items\Services & Pegasus Flightdeck back up\Hrs Target\" & Sheets(1).Range("A1").Value)
    With wbRead.Sheets(1)
    ThisWorkbook.Sheets(2).Range("a:ah").Value = .Range("A:ah").Value
    End With
    wbRead.Close True
    Sheets("Sheet1").Range("B:D").ClearContents
    Sheets("Sheet2").Range("A:D,F:L,N:R,T:AF").Delete Shift:=xlToLeft
    Sheets("Sheet2").Range("1:8,10:11").Delete Shift:=xlUp
    ActiveWorkbook.Worksheets("Sheet2").Sort.SortFields.clear
    ActiveWorkbook.Worksheets("Sheet2").Sort.SortFields.Add Key:=Range("D1"), _
    SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet2").Sort
    .SetRange Range("A2:D1217")
    .Header = xlNo
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
    End With
    Sheets("Sheet2").Activate
    With Intersect(ActiveSheet.UsedRange, ActiveSheet.Columns("d"))
    .AutoFilter 1, ">30"
    .Offset(1).EntireRow.Delete
    .AutoFilter
    End With
    With Intersect(ActiveSheet.UsedRange, ActiveSheet.Columns("c"))
    .AutoFilter 1, "=0"
    .Offset(1).EntireRow.Delete
    .AutoFilter
    End With
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    "Sheet2!R1C1:R65536C4", Version:=xlPivotTableVersion10).CreatePivotTable _
    TableDestination:="Sheet1!R2C2", TableName:="PivotTable1", DefaultVersion _
    :=xlPivotTableVersion10
    Sheets("Sheet1").Select
    Cells(2, 2).Select
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("Material")
    .Orientation = xlRowField
    .Position = 1
    End With
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("Gate")
    .Orientation = xlRowField
    .Position = 2
    End With
    ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
    "PivotTable1").PivotFields("Total WIP"), "Count of Total WIP", xlCount
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of Total WIP")
    .Caption = "Sum of Total WIP"
    .Function = xlSum
    End With

    Sheets(3).Select

    ActiveWorkbook.save

    End Sub


    Private Sub CommandButton1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

    End Sub

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Run Time error 7 - out of memory

    replace
    Application.ScreenUpdating = False
    with
            ViewMode = ActiveWindow.View
            ActiveWindow.View = xlNormalView
            activesheet.DisplayPageBreaks = False
    
        With Application
            CalcMode = .Calculation
            .Calculation = xlCalculationManual
            .ScreenUpdating = False
        End With
    then to reverse it, put this right before the end sub

        ActiveWindow.View = ViewMode
        With Application
            .ScreenUpdating = True
            .Calculation = CalcMode
        End With
    the above code will turn off auto calculation which takes a lot of resources, it also switches you into normal view mode

  3. #3
    Registered User
    Join Date
    01-24-2013
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Run Time error 7 - out of memory

    thanks but I still can not get it working. Have you any other suggestions? Perhaps I am doing it wrong?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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