Consulting

Results 1 to 3 of 3

Thread: VBA code mysteriously timing out

  1. #1

    VBA code mysteriously timing out

    The code below sorts all the data by item and then applies a subtotal to the data and then takes it to the 2nd row level:

    Sub datadump()
    Application.ScreenUpdating = False
        
    
    On Error Resume Next   'turn off error reporting
       ActiveSheet.ShowAllData
       On Error GoTo 0   'turn error reporting back on
    
     
    Range("D2").CurrentRegion.Sort Key1:=Range("D2"), _
     DataOption1:=xlSortTextAsNumbers, _
     Header:=xlYes
     
    lastvalue = "A" & Range("A2").End(xlDown).Offset(1).Row & ":" & "A" & Range("A2").End(xlDown).End(xlDown).Row
    Range(lastvalue).EntireRow.Delete
    ActiveSheet.UsedRange
    resetingcolumns = ActiveSheet.UsedRange.Columns.Count
     Range("A1").Select
     Selection.Subtotal GroupBy:=4, Function:=xlSum, TotalList:=Array(7, 9), _
            Replace:=True, PageBreaks:=False, SummaryBelowData:=True
        ActiveSheet.Outline.ShowLevels RowLevels:=2
        
    End Sub
    For some reason the "Activesheet.outline.showlevels rowlevels:=2" is being skipped. Could someone help me out and tell me why that line of code is being skipped. When I performed this exercise on smaller files the entire code works. If you would like the file that I am having an issue with I can send it to you to look at, however the file is 3.57 mb which is to big to post here.

  2. #2
    VBAX Expert Leith Ross's Avatar
    Joined
    Oct 2012
    Location
    San Francisco, California
    Posts
    552
    Location
    Hello greyangel,

    You might be able to post the workbook if you zip it.
    Sincerely,
    Leith Ross

    "1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG"

  3. #3
    Once I restarted my computer the Macro started to work correctly. I don't know what the issue was but now it is fixed.

Posting Permissions

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