Home

Why so slow and periodic "not responding" in Excel 2016?

%3CLINGO-SUB%20id%3D%22lingo-sub-614113%22%20slang%3D%22en-US%22%3EWhy%20so%20slow%20and%20periodic%20%22not%20responding%22%20in%20Excel%202016%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-614113%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20macro%20works%20perfectly%20but%20runs%20quite%20slow%20and%20periodically%20the%20screen%20goes%20white%2C%20says%20excel%20unresponsive%2C%20but%20then%20continues%20on%20to%20completion%20without%20trouble.%20Someone%20mention%20before%20that%20I%20should%20remove%20code%20from%20area%20where%20the%20macro%20%22paste%20values%22%20but%20the%20%22paste%20from%22%20cells%20are%20different%20sizes%20than%20the%20%22paste%20to%22%20cells%20and%20the%20code%20they%20suggested%20did%20not%20work.%20Here%20is%20the%20code.%20Please%20let%20me%20know%20if%20you%20have%20suggestions%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESub%20GreaterThan4k()%3CBR%20%2F%3E'%3CBR%20%2F%3E'%20GreaterThan4k%20Macro%3CBR%20%2F%3E'%3CBR%20%2F%3ERange(%22R2%22).Select%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22S2%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteValues%2C%20Operation%3A%3DxlNone%2C%20SkipBlanks%20_%3CBR%20%2F%3E%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3E%3CBR%20%2F%3EApplication.EnableEvents%20%3D%20False%3CBR%20%2F%3E%3CBR%20%2F%3ERange(%22R2%2CT2%3AT27%2CU2%3AU11%2CV2%3AW5%2CU30%3AU629%22).Select%3CBR%20%2F%3ERange(%22U30%22).Activate%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.ClearContents%3CBR%20%2F%3E%3CBR%20%2F%3EApplication.EnableEvents%20%3D%20True%3CBR%20%2F%3E%3CBR%20%2F%3EApplication.EnableEvents%20%3D%20True%3CBR%20%2F%3ERange(%22B30%3AAX629%22).Select%3CBR%20%2F%3ERange(%22AX629%22).Activate%3CBR%20%2F%3EActiveWorkbook.Worksheets(%22Sheet1%22).Sort.SortFields.Clear%3CBR%20%2F%3EActiveWorkbook.Worksheets(%22Sheet1%22).Sort.SortFields.Add2%20Key%3A%3DRange(%20_%3CBR%20%2F%3E%22R30%3AR629%22)%2C%20SortOn%3A%3DxlSortOnValues%2C%20Order%3A%3DxlAscending%2C%20DataOption%3A%3D%20_%3CBR%20%2F%3ExlSortNormal%3CBR%20%2F%3EWith%20ActiveWorkbook.Worksheets(%22Sheet1%22).Sort%3CBR%20%2F%3E.SetRange%20Range(%22B30%3AAX629%22)%3CBR%20%2F%3E.Header%20%3D%20xlGuess%3CBR%20%2F%3E.MatchCase%20%3D%20False%3CBR%20%2F%3E.Orientation%20%3D%20xlTopToBottom%3CBR%20%2F%3E.SortMethod%20%3D%20xlPinYin%3CBR%20%2F%3E.Apply%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3E'%3CBR%20%2F%3ERange(%22S2%22).Select%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22R2%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteValues%2C%20Operation%3A%3DxlNone%2C%20SkipBlanks%20_%3CBR%20%2F%3E%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3ERange(%22R2%22).Select%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22T2%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteValues%2C%20Operation%3A%3DxlNone%2C%20SkipBlanks%20_%3CBR%20%2F%3E%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3ERange(%22Q10%22).Select%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22T3%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteValues%2C%20Operation%3A%3DxlNone%2C%20SkipBlanks%20_%3CBR%20%2F%3E%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3ERange(%22AT30%3AAT37%22).Select%3CBR%20%2F%3ERange(%22AT37%22).Activate%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22T4%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteValues%2C%20Operation%3A%3DxlNone%2C%20SkipBlanks%20_%3CBR%20%2F%3E%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3ERange(%22Q19%22).Select%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22U2%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteValues%2C%20Operation%3A%3DxlNone%2C%20SkipBlanks%20_%3CBR%20%2F%3E%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3ERange(%22P10%22).Select%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22U3%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteValues%2C%20Operation%3A%3DxlNone%2C%20SkipBlanks%20_%3CBR%20%2F%3E%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3ERange(%22U2%22).Select%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22R2%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteValues%2C%20Operation%3A%3DxlNone%2C%20SkipBlanks%20_%3CBR%20%2F%3E%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3ERange(%22AS30%3AAS31%22).Select%3CBR%20%2F%3ERange(%22AS31%22).Activate%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22U4%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteValues%2C%20Operation%3A%3DxlNone%2C%20SkipBlanks%20_%3CBR%20%2F%3E%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3ERange(%22P19%22).Select%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22V2%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteValues%2C%20Operation%3A%3DxlNone%2C%20SkipBlanks%20_%3CBR%20%2F%3E%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3ERange(%22P10%22).Select%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22V3%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteValues%2C%20Operation%3A%3DxlNone%2C%20SkipBlanks%20_%3CBR%20%2F%3E%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3ERange(%22V2%22).Select%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22R2%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteValues%2C%20Operation%3A%3DxlNone%2C%20SkipBlanks%20_%3CBR%20%2F%3E%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3ERange(%22AS30%3AAS31%22).Select%3CBR%20%2F%3ERange(%22AS31%22).Activate%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22V4%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteValues%2C%20Operation%3A%3DxlNone%2C%20SkipBlanks%20_%3CBR%20%2F%3E%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3ERange(%22R2%22).Select%3CBR%20%2F%3EMsgBox%20%22There%20may%20be%20SUGGESTED%20SHARES%20to%20utilize%20unallocated%20funds.%20Add%20ADDITIONAL%20SHARES%20now.%22%3CBR%20%2F%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-614113%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-615865%22%20slang%3D%22en-US%22%3ERe%3A%20Why%20so%20slow%20and%20periodic%20%22not%20responding%22%20in%20Excel%202016%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-615865%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F235152%22%20target%3D%22_blank%22%3E%40Greg%20Bonaparte%3C%2FA%3E%20A%20macro%20works%20more%20efficient%20without%20all%20the%20selecting%20and%20activating.%20Also%2C%20transferring%20values%20directly%2C%20rather%20than%20through%20a%20copy%20and%20paste%20is%20faster.%3C%2FP%3E%0A%3CP%3EI%20have%20tried%20my%20best%20to%20convert%20all%20cell%20addresses%20properly%2C%20but%20this%20does%20need%20a%20thorough%20check%20against%20your%20own%20macro%3A%3C%2FP%3E%0A%3CPRE%3ESub%20GreaterThan4k()%0A'%0A'%20GreaterThan4k%20Macro%0A'%0A%20%20%20%20Application.ScreenUpdating%20%3D%20False%0A%20%20%20%20Application.EnableEvents%20%3D%20False%0A%0A%20%20%20%20Range(%22S2%22).Value%20%3D%20Range(%22R2%22).Value%0A%0A%20%20%20%20Range(%22R2%2CT2%3AT27%2CU2%3AU11%2CV2%3AW5%2CU30%3AU629%22).ClearContents%0A%0A%20%20%20%20ActiveWorkbook.Worksheets(%22Sheet1%22).Sort.SortFields.Clear%0A%20%20%20%20ActiveWorkbook.Worksheets(%22Sheet1%22).Sort.SortFields.Add2%20Key%3A%3DRange(%20_%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22R30%3AR629%22)%2C%20SortOn%3A%3DxlSortOnValues%2C%20Order%3A%3DxlAscending%2C%20DataOption%3A%3D%20_%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20xlSortNormal%0A%20%20%20%20With%20ActiveWorkbook.Worksheets(%22Sheet1%22).Sort%0A%20%20%20%20%20%20%20%20.SetRange%20Range(%22B30%3AAX629%22)%0A%20%20%20%20%20%20%20%20.Header%20%3D%20xlGuess%0A%20%20%20%20%20%20%20%20.MatchCase%20%3D%20False%0A%20%20%20%20%20%20%20%20.Orientation%20%3D%20xlTopToBottom%0A%20%20%20%20%20%20%20%20.SortMethod%20%3D%20xlPinYin%0A%20%20%20%20%20%20%20%20.Apply%0A%20%20%20%20End%20With%0A%20%20%20%20'%0A%20%20%20%20%0A%20%20%20%20Range(%22R2%22).Value%20%3D%20Range(%22S2%22).Value%0A%20%20%20%20Range(%22T2%22).Value%20%3D%20Range(%22R2%22).Value%0A%20%20%20%20Range(%22T3%22).Value%20%3D%20Range(%22Q10%22).Value%0A%20%20%20%20Range(%22T4%3AT11%22).Value%20%3D%20Range(%22AT30%3AAT37%22).Value%0A%20%20%20%20Range(%22U2%22).Value%20%3D%20Range(%22Q19%22).Value%0A%20%20%20%20Range(%22U3%22).Value%20%3D%20Range(%22P10%22).Value%0A%20%20%20%20Range(%22R2%22).Value%20%3D%20Range(%22U2%22).Value%0A%20%20%20%20Range(%22U4%3AU5%22).Value%20%3D%20Range(%22AS30%3AAS31%22).Value%0A%20%20%20%20Range(%22V2%22).Value%20%3D%20Range(%22P19%22).Value%0A%20%20%20%20Range(%22V3%22).Value%20%3D%20Range(%22P10%22).Value%0A%20%20%20%20Range(%22R2%22).Value%20%3D%20Range(%22V2%22).Value%0A%20%20%20%20Range(%22V4%3AV5%22).Value%20%3D%20Range(%22AS30%3AAS31%22).Value%0A%20%20%20%20Range(%22R2%22).Select%0A%20%20%20%20Application.EnableEvents%20%3D%20True%0A%20%20%20%20Application.ScreenUpdating%20%3D%20True%0A%20%20%20%20MsgBox%20%22There%20may%20be%20SUGGESTED%20SHARES%20to%20utilize%20unallocated%20funds.%20Add%20ADDITIONAL%20SHARES%20now.%22%0AEnd%20Sub%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Greg Bonaparte
Contributor

This macro works perfectly but runs quite slow and periodically the screen goes white, says excel unresponsive, but then continues on to completion without trouble. Someone mention before that I should remove code from area where the macro "paste values" but the "paste from" cells are different sizes than the "paste to" cells and the code they suggested did not work. Here is the code. Please let me know if you have suggestions:

 

Sub GreaterThan4k()
'
' GreaterThan4k Macro
'
Range("R2").Select
Selection.Copy
Range("S2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Application.EnableEvents = False

Range("R2,T2:T27,U2:U11,V2:W5,U30:U629").Select
Range("U30").Activate
Application.CutCopyMode = False
Selection.ClearContents

Application.EnableEvents = True

Application.EnableEvents = True
Range("B30:AX629").Select
Range("AX629").Activate
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add2 Key:=Range( _
"R30:R629"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("B30:AX629")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'
Range("S2").Select
Selection.Copy
Range("R2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("R2").Select
Application.CutCopyMode = False
Selection.Copy
Range("T2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("Q10").Select
Application.CutCopyMode = False
Selection.Copy
Range("T3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("AT30:AT37").Select
Range("AT37").Activate
Application.CutCopyMode = False
Selection.Copy
Range("T4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("Q19").Select
Application.CutCopyMode = False
Selection.Copy
Range("U2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("P10").Select
Application.CutCopyMode = False
Selection.Copy
Range("U3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("U2").Select
Application.CutCopyMode = False
Selection.Copy
Range("R2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("AS30:AS31").Select
Range("AS31").Activate
Application.CutCopyMode = False
Selection.Copy
Range("U4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("P19").Select
Application.CutCopyMode = False
Selection.Copy
Range("V2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("P10").Select
Application.CutCopyMode = False
Selection.Copy
Range("V3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("V2").Select
Application.CutCopyMode = False
Selection.Copy
Range("R2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("AS30:AS31").Select
Range("AS31").Activate
Application.CutCopyMode = False
Selection.Copy
Range("V4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("R2").Select
MsgBox "There may be SUGGESTED SHARES to utilize unallocated funds. Add ADDITIONAL SHARES now."

End Sub

1 Reply

@Greg Bonaparte A macro works more efficient without all the selecting and activating. Also, transferring values directly, rather than through a copy and paste is faster.

I have tried my best to convert all cell addresses properly, but this does need a thorough check against your own macro:

Sub GreaterThan4k()
'
' GreaterThan4k Macro
'
    Application.ScreenUpdating = False
    Application.EnableEvents = False

    Range("S2").Value = Range("R2").Value

    Range("R2,T2:T27,U2:U11,V2:W5,U30:U629").ClearContents

    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add2 Key:=Range( _
                                                                  "R30:R629"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
                                                             xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SetRange Range("B30:AX629")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    '
    
    Range("R2").Value = Range("S2").Value
    Range("T2").Value = Range("R2").Value
    Range("T3").Value = Range("Q10").Value
    Range("T4:T11").Value = Range("AT30:AT37").Value
    Range("U2").Value = Range("Q19").Value
    Range("U3").Value = Range("P10").Value
    Range("R2").Value = Range("U2").Value
    Range("U4:U5").Value = Range("AS30:AS31").Value
    Range("V2").Value = Range("P19").Value
    Range("V3").Value = Range("P10").Value
    Range("R2").Value = Range("V2").Value
    Range("V4:V5").Value = Range("AS30:AS31").Value
    Range("R2").Select
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    MsgBox "There may be SUGGESTED SHARES to utilize unallocated funds. Add ADDITIONAL SHARES now."
End Sub
Related Conversations