Consulting

Results 1 to 2 of 2

Thread: Code running amazing slow when file is shared

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Oct 2012
    Posts
    1
    Location

    Cool Code running amazing slow when file is shared

    All,

    I have a spread sheet that I fill combo box off of a sorted and filtered list. When the file is not shared it runs in less than a second, however once it is share it seems to slow down in the below section of code and I can't for the life of me figure out why. I have remove parts of the code and still no luck, maybe I have been looking at it too long. Any help would be appreciated.



    [vba]Private Sub ComboBox02_Click()
    Dim lr5, lr6, lr10 As Long
    Dim item3 As Range
    'Application.ScreenUpdating = False
    Sheets("Analysis").Select
    ActiveSheet.Range("ac2:Ac5").Select
    Selection.Clear
    ThisWorkbook.Sheets("Processing Sheet").Visible = True
    Sheets("Processing Sheet").Select
    oo:
    If Not ActiveSheet.AutoFilter.Filters(43).On Then
    ActiveSheet.Range("B:B").Select
    Selection.AutoFilter Field:=2, Criteria1:=Sheets("Analysis").Range("C3")
    Sheets("Formula Sheet").Visible = True
    Sheets("Formula Sheet").Select
    tttt:
    ActiveSheet.FilterMode = True
    ActiveSheet.ShowAllData
    Sheets("Processing Sheet").Select
    ActiveSheet.Range("AQ:AQ").Select 'added by ktg to make the scope and active list
    Selection.Copy
    Sheets("Formula Sheet").Select
    ActiveSheet.Range("w1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    lr5 = Sheets("Formula Sheet").Cells(Rows.Count, "W").End(xlUp).Row
    ActiveWorkbook.Worksheets("Formula Sheet").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Formula Sheet").Sort.SortFields.Add Key:=Range( _
    "w1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
    xlSortNormal
    With ActiveWorkbook.Worksheets("Formula Sheet").Sort
    .SetRange Range("w1" & ":w" & lr5)
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
    End With
    'lr6 = Sheets("Formula Sheet").Cells(Rows.Count, "W").End(xlUp).Row
    ActiveSheet.Range("x2" & ":" & "x" & lr5).Select
    Selection.Clear
    Selection.FormulaR1C1 = "=IF(R[-1]C[-1]=RC[-1],R[-1]C+1,1)"
    ActiveSheet.Range("x:x").Select 'set column you filter for probable names here
    Selection.AutoFilter Field:=7, Criteria1:="1" 'end of add
    ActiveSheet.Range("w1" & ":w" & lr5).Select
    Selection.Copy
    Sheets("Analysis").Select
    ActiveSheet.Range("Ac1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    'Else
    'ActiveSheet.ShowAllData
    'GoTo tttt:
    'End If
    Sheets("Analysis").ComboBox03.Clear
    'Sheets("Analysis").ComboBox03.AddItem "(Select All)"
    lr10 = Sheets("Analysis").Cells(Rows.Count, "Ac").End(xlUp).Row
    For Each item3 In Sheets("analysis").Range("AC2" & ":AC" & lr10)
    Sheets("Analysis").ComboBox03.AddItem item3.Value
    Next item3
    Else
    'Need to work on this
    ActiveSheet.Range("$A$1:$BA$7633").AutoFilter Field:=43
    GoTo oo:
    End If
    'If ActiveSheet.Range("c4").Value = "" Then
    'ActiveSheet.ComboBox03.Value = "Select a Scope"
    'Else
    ActiveSheet.ComboBox03.Value = "Select a Scope"
    'End If
    ThisWorkbook.Sheets("Processing Sheet").Visible = False
    'Application.ScreenUpdating = True
    ActiveSheet.Range("B5").Select
    End Sub[/vba]
    Last edited by Aussiebear; 10-10-2012 at 04:30 PM. Reason: Added the correct tags to the supplied code

Posting Permissions

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